mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19907 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
40c293bd24
commit
6dfd0f28f4
@ -1016,7 +1016,7 @@ gnc_locale_default_currency (void)
|
||||
|
||||
static gnc_commodity *
|
||||
gnc_default_currency_common (gchar *requested_currency,
|
||||
const gchar *gconf_section)
|
||||
const gchar *gconf_section)
|
||||
{
|
||||
gnc_commodity *currency = NULL;
|
||||
gchar *choice, *mnemonic;
|
||||
|
@ -279,15 +279,15 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
||||
filepath = gnc_uri_get_path ( book_id );
|
||||
|
||||
if ( !create &&
|
||||
!g_file_test( filepath, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS ) )
|
||||
!g_file_test( filepath, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS ) )
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_FILEIO_FILE_NOT_FOUND );
|
||||
LEAVE(" ");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( create && !force &&
|
||||
g_file_test( filepath, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS ) )
|
||||
if ( create && !force &&
|
||||
g_file_test( filepath, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS ) )
|
||||
{
|
||||
qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
|
||||
LEAVE("Might clobber, no force");
|
||||
@ -312,7 +312,7 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
||||
basename = g_path_get_basename( filepath );
|
||||
g_free ( filepath );
|
||||
dbi_conn_error_handler( be->conn, sqlite3_error_fn, be );
|
||||
/* dbi-sqlite3 documentation says that sqlite3 doesn't take a "host" option */
|
||||
/* dbi-sqlite3 documentation says that sqlite3 doesn't take a "host" option */
|
||||
result = dbi_conn_set_option( be->conn, "host", "localhost" );
|
||||
if ( result < 0 )
|
||||
{
|
||||
@ -340,7 +340,7 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
||||
result = dbi_conn_connect( be->conn );
|
||||
g_free( basename );
|
||||
g_free( dirname );
|
||||
/* Need some better error handling here. In particular, need to emit a QOF_ERROR_LOCKED if the database is in use by another process. */
|
||||
/* Need some better error handling here. In particular, need to emit a QOF_ERROR_LOCKED if the database is in use by another process. */
|
||||
if ( result < 0 )
|
||||
{
|
||||
PERR( "Unable to connect to %s: %d\n", book_id, result );
|
||||
@ -351,9 +351,9 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
||||
|
||||
if ( !gnc_dbi_lock_database( qbe, ignore_lock ) )
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
|
||||
LEAVE( "Locked" );
|
||||
return;
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
|
||||
LEAVE( "Locked" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( be->sql_be.conn != NULL )
|
||||
@ -416,14 +416,14 @@ mysql_error_fn( dbi_conn conn, void* user_data )
|
||||
{
|
||||
PERR( "DBI error: %s - Giving up after %d consecutive attempts.\n", msg, DBI_MAX_CONN_ATTEMPTS );
|
||||
if (dbi_conn)
|
||||
gnc_dbi_set_error( dbi_conn, ERR_BACKEND_CANT_CONNECT, 0, FALSE );
|
||||
gnc_dbi_set_error( dbi_conn, ERR_BACKEND_CANT_CONNECT, 0, FALSE );
|
||||
dbi_conn->conn_ok = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PINFO( "DBI error: %s - Reconnecting...\n", msg );
|
||||
if (dbi_conn)
|
||||
gnc_dbi_set_error( dbi_conn, ERR_BACKEND_CANT_CONNECT, 1, TRUE );
|
||||
gnc_dbi_set_error( dbi_conn, ERR_BACKEND_CANT_CONNECT, 1, TRUE );
|
||||
dbi_conn->conn_ok = TRUE;
|
||||
(void)dbi_conn_connect( conn );
|
||||
}
|
||||
@ -502,112 +502,112 @@ gnc_dbi_lock_database ( QofBackend* qbe, gboolean ignore_lock )
|
||||
dbi_conn dcon = qe->conn;
|
||||
dbi_result result;
|
||||
const gchar *dbname = dbi_conn_get_option( dcon, "dbname" );
|
||||
/* Create the table if it doesn't exist */
|
||||
/* Create the table if it doesn't exist */
|
||||
result = dbi_conn_get_table_list( dcon, dbname, "GNCLOCK");
|
||||
if (!( result && dbi_result_get_numrows( result ) ))
|
||||
{
|
||||
if ( result )
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_queryf( dcon, "CREATE TABLE GNCLOCK ( Hostname varchar(%d), PID int )", GNC_HOST_NAME_MAX );
|
||||
if ( dbi_conn_error( dcon, NULL ) )
|
||||
{
|
||||
const gchar *errstr;
|
||||
dbi_conn_error( dcon, &errstr );
|
||||
PERR( "Error %s creating lock table", errstr );
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
return FALSE;
|
||||
}
|
||||
if ( result )
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_queryf( dcon, "CREATE TABLE GNCLOCK ( Hostname varchar(%d), PID int )", GNC_HOST_NAME_MAX );
|
||||
if ( dbi_conn_error( dcon, NULL ) )
|
||||
{
|
||||
const gchar *errstr;
|
||||
dbi_conn_error( dcon, &errstr );
|
||||
PERR( "Error %s creating lock table", errstr );
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
return FALSE;
|
||||
}
|
||||
if ( result )
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
/* Protect everything with a single transaction to prevent races */
|
||||
/* Protect everything with a single transaction to prevent races */
|
||||
if ( (result = dbi_conn_query( dcon, "BEGIN" )) )
|
||||
{
|
||||
/* Check for an existing entry; delete it if ignore_lock is true, otherwise fail */
|
||||
gchar hostname[ GNC_HOST_NAME_MAX + 1 ];
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "SELECT * FROM GNCLOCK" );
|
||||
if ( result && dbi_result_get_numrows( result ) )
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
if ( !ignore_lock )
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
|
||||
/* FIXME: After enhancing the qof_backend_error mechanism, report in the dialog what is the hostname of the machine holding the lock. */
|
||||
dbi_conn_query( dcon, "ROLLBACK" );
|
||||
return FALSE;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "DELETE FROM GNCLOCK" );
|
||||
if ( !result)
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
/* Add an entry and commit the transaction */
|
||||
memset( hostname, 0, sizeof(hostname) );
|
||||
gethostname( hostname, GNC_HOST_NAME_MAX );
|
||||
result = dbi_conn_queryf( dcon,
|
||||
"INSERT INTO GNCLOCK VALUES ('%s', '%d')",
|
||||
hostname, (int)GETPID() );
|
||||
if ( !result)
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "COMMIT" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
/* Check for an existing entry; delete it if ignore_lock is true, otherwise fail */
|
||||
gchar hostname[ GNC_HOST_NAME_MAX + 1 ];
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "SELECT * FROM GNCLOCK" );
|
||||
if ( result && dbi_result_get_numrows( result ) )
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
if ( !ignore_lock )
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
|
||||
/* FIXME: After enhancing the qof_backend_error mechanism, report in the dialog what is the hostname of the machine holding the lock. */
|
||||
dbi_conn_query( dcon, "ROLLBACK" );
|
||||
return FALSE;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "DELETE FROM GNCLOCK" );
|
||||
if ( !result)
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
/* Add an entry and commit the transaction */
|
||||
memset( hostname, 0, sizeof(hostname) );
|
||||
gethostname( hostname, GNC_HOST_NAME_MAX );
|
||||
result = dbi_conn_queryf( dcon,
|
||||
"INSERT INTO GNCLOCK VALUES ('%s', '%d')",
|
||||
hostname, (int)GETPID() );
|
||||
if ( !result)
|
||||
{
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "COMMIT" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
/* Couldn't get a transaction (probably couldn't get a lock), so fail */
|
||||
/* Couldn't get a transaction (probably couldn't get a lock), so fail */
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -624,77 +624,77 @@ gnc_dbi_unlock( QofBackend *qbe )
|
||||
g_return_if_fail( dbi_conn_error( dcon, NULL ) == 0 );
|
||||
|
||||
dbname = dbi_conn_get_option( dcon, "dbname" );
|
||||
/* Check if the lock table exists */
|
||||
/* Check if the lock table exists */
|
||||
result = dbi_conn_get_table_list( dcon, dbname, "GNCLOCK");
|
||||
if (!( result && dbi_result_get_numrows( result ) ))
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
PWARN("No lock table in database, so not unlocking it.");
|
||||
return;
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
PWARN("No lock table in database, so not unlocking it.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( result = dbi_conn_query( dcon, "BEGIN" )) )
|
||||
{
|
||||
/* Delete the entry if it's our hostname and PID */
|
||||
gchar hostname[ GNC_HOST_NAME_MAX + 1 ];
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
memset( hostname, 0, sizeof(hostname) );
|
||||
gethostname( hostname, GNC_HOST_NAME_MAX );
|
||||
result = dbi_conn_queryf( dcon, "SELECT * FROM GNCLOCK WHERE Hostname = '%s' AND PID = '%d'", hostname, (int)GETPID() );
|
||||
if ( result && dbi_result_get_numrows( result ) )
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "DELETE FROM GNCLOCK" );
|
||||
if ( !result)
|
||||
{
|
||||
PERR("Failed to delete the lock entry");
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "COMMIT" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
PWARN("There was no lock entry in the Lock table");
|
||||
return;
|
||||
/* Delete the entry if it's our hostname and PID */
|
||||
gchar hostname[ GNC_HOST_NAME_MAX + 1 ];
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
memset( hostname, 0, sizeof(hostname) );
|
||||
gethostname( hostname, GNC_HOST_NAME_MAX );
|
||||
result = dbi_conn_queryf( dcon, "SELECT * FROM GNCLOCK WHERE Hostname = '%s' AND PID = '%d'", hostname, (int)GETPID() );
|
||||
if ( result && dbi_result_get_numrows( result ) )
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "DELETE FROM GNCLOCK" );
|
||||
if ( !result)
|
||||
{
|
||||
PERR("Failed to delete the lock entry");
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "COMMIT" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
result = dbi_conn_query( dcon, "ROLLBACK" );
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
PWARN("There was no lock entry in the Lock table");
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
dbi_result_free( result );
|
||||
result = NULL;
|
||||
}
|
||||
PWARN("Unable to get a lock on LOCK, so failed to clear the lock entry.");
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
@ -750,12 +750,12 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
|
||||
result = dbi_conn_connect( be->conn );
|
||||
if ( result == 0 )
|
||||
{
|
||||
if (create && !force && save_may_clobber_data( qbe ) )
|
||||
{
|
||||
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
||||
PWARN("Databse already exists, Might clobber it.");
|
||||
goto exit;
|
||||
}
|
||||
if (create && !force && save_may_clobber_data( qbe ) )
|
||||
{
|
||||
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
||||
PWARN("Databse already exists, Might clobber it.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
success = gnc_dbi_lock_database ( qbe, ignore_lock );
|
||||
}
|
||||
@ -872,19 +872,19 @@ pgsql_error_fn( dbi_conn conn, void* user_data )
|
||||
}
|
||||
else if ( g_strrstr( msg, "server closed the connection unexpectedly" ) ) // Connection lost
|
||||
{
|
||||
if ( dbi_conn == NULL )
|
||||
{
|
||||
PWARN( "DBI Error: Connection lost, connection pointer invalid");
|
||||
return;
|
||||
}
|
||||
if ( dbi_conn == NULL )
|
||||
{
|
||||
PWARN( "DBI Error: Connection lost, connection pointer invalid");
|
||||
return;
|
||||
}
|
||||
PINFO( "DBI error: %s - Reconnecting...\n", msg );
|
||||
gnc_dbi_set_error( dbi_conn, ERR_BACKEND_CONN_LOST, 1, TRUE );
|
||||
dbi_conn->conn_ok = TRUE;
|
||||
(void)dbi_conn_connect( conn );
|
||||
}
|
||||
else if ( dbi_conn &&
|
||||
( g_str_has_prefix( msg, "connection pointer is NULL" ) ||
|
||||
g_str_has_prefix(msg, "could not connect to server" ) ) ) // No connection
|
||||
else if ( dbi_conn &&
|
||||
( g_str_has_prefix( msg, "connection pointer is NULL" ) ||
|
||||
g_str_has_prefix(msg, "could not connect to server" ) ) ) // No connection
|
||||
{
|
||||
if (dbi_conn->error_repeat >= DBI_MAX_CONN_ATTEMPTS )
|
||||
{
|
||||
@ -935,10 +935,10 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
||||
&username, &password, &dbname );
|
||||
if ( portnum == 0 )
|
||||
portnum = PGSQL_DEFAULT_PORT;
|
||||
/* Postgres's SQL interface coerces identifiers to lower case, but the
|
||||
* C interface is case-sensitive. This results in a mixed-case dbname
|
||||
* being created (with a lower case name) but then dbi can't conect to
|
||||
* it. To work around this, coerce the name to lowercase first. */
|
||||
/* Postgres's SQL interface coerces identifiers to lower case, but the
|
||||
* C interface is case-sensitive. This results in a mixed-case dbname
|
||||
* being created (with a lower case name) but then dbi can't conect to
|
||||
* it. To work around this, coerce the name to lowercase first. */
|
||||
dbnamelc = g_utf8_strdown( dbname, -1 );
|
||||
|
||||
// Try to connect to the db. If it doesn't exist and the create
|
||||
@ -964,12 +964,12 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
||||
result = dbi_conn_connect( be->conn );
|
||||
if ( result == 0 )
|
||||
{
|
||||
if (create && !force && save_may_clobber_data( qbe ) )
|
||||
{
|
||||
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
||||
PWARN("Databse already exists, Might clobber it.");
|
||||
goto exit;
|
||||
}
|
||||
if (create && !force && save_may_clobber_data( qbe ) )
|
||||
{
|
||||
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
||||
PWARN("Databse already exists, Might clobber it.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
success = gnc_dbi_lock_database ( qbe, ignore_lock );
|
||||
}
|
||||
@ -1008,7 +1008,7 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||
goto exit;
|
||||
}
|
||||
dbi_conn_queryf( be->conn, "ALTER DATABASE %s SET standard_conforming_strings TO on", dbnamelc );
|
||||
dbi_conn_queryf( be->conn, "ALTER DATABASE %s SET standard_conforming_strings TO on", dbnamelc );
|
||||
dbi_conn_close( be->conn );
|
||||
|
||||
// Try again to connect to the db
|
||||
@ -1072,7 +1072,7 @@ gnc_dbi_session_end( QofBackend *be_start )
|
||||
|
||||
if ( be->conn != NULL )
|
||||
{
|
||||
gnc_dbi_unlock( be_start );
|
||||
gnc_dbi_unlock( be_start );
|
||||
dbi_conn_close( be->conn );
|
||||
be->conn = NULL;
|
||||
}
|
||||
@ -1140,8 +1140,8 @@ save_may_clobber_data( QofBackend* qbe )
|
||||
result = dbi_conn_get_table_list( be->conn, dbname, NULL );
|
||||
if ( result )
|
||||
{
|
||||
retval = dbi_result_get_numrows( result ) > 0;
|
||||
dbi_result_free( result );
|
||||
retval = dbi_result_get_numrows( result ) > 0;
|
||||
dbi_result_free( result );
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -1171,10 +1171,10 @@ gnc_dbi_sync_all( QofBackend* qbe, /*@ dependent @*/ QofBook *book )
|
||||
const gchar* table_name = (const gchar*)node->data;
|
||||
dbi_result result;
|
||||
/* Don't delete the lock table */
|
||||
if ( g_strcmp0(table_name, "GNCLOCK") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( g_strcmp0(table_name, "GNCLOCK") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
do
|
||||
{
|
||||
gnc_dbi_init_error( ((GncDbiSqlConnection*)(be->sql_be.conn)) );
|
||||
@ -1282,7 +1282,7 @@ static QofBackend*
|
||||
new_backend( void (*session_begin)( QofBackend *, QofSession *, const gchar *,
|
||||
/*@ unused @*/ gboolean,
|
||||
/*@ unused @*/ gboolean,
|
||||
/*@ unused @*/ gboolean ) )
|
||||
/*@ unused @*/ gboolean ) )
|
||||
{
|
||||
GncDbiBackend *dbi_be;
|
||||
QofBackend *be;
|
||||
@ -1522,9 +1522,9 @@ row_dispose( /*@ only @*/ GncSqlRow* row )
|
||||
{
|
||||
for ( node = dbi_row->gvalue_list; node != NULL; node = node->next )
|
||||
{
|
||||
GValue* value;
|
||||
if ( !G_IS_VALUE(node->data) )
|
||||
continue;
|
||||
GValue* value;
|
||||
if ( !G_IS_VALUE(node->data) )
|
||||
continue;
|
||||
value = (GValue*)node->data;
|
||||
if ( G_VALUE_HOLDS_STRING(value) )
|
||||
{
|
||||
@ -2416,7 +2416,7 @@ conn_create_index( /*@ unused @*/ GncSqlConnection* conn, /*@ unused @*/ const g
|
||||
|
||||
static gboolean
|
||||
conn_add_columns_to_table( /*@ unused @*/ GncSqlConnection* conn, /*@ unused @*/ const gchar* table_name,
|
||||
GList* col_info_list )
|
||||
GList* col_info_list )
|
||||
{
|
||||
GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
|
||||
gchar* ddl;
|
||||
|
@ -3154,7 +3154,7 @@ gnc_sql_upgrade_table( GncSqlBackend* be, const gchar* table_name,
|
||||
|
||||
/* Adds one or more columns to an existing table. */
|
||||
gboolean gnc_sql_add_columns_to_table( GncSqlBackend* be, const gchar* table_name,
|
||||
const GncSqlColumnTableEntry* new_col_table )
|
||||
const GncSqlColumnTableEntry* new_col_table )
|
||||
{
|
||||
GList* col_info_list = NULL;
|
||||
gboolean ok = FALSE;
|
||||
|
@ -728,7 +728,7 @@ void gnc_sql_upgrade_table( GncSqlBackend* be, const gchar* table_name,
|
||||
* @return TRUE if successful, FALSE if unsuccessful
|
||||
*/
|
||||
gboolean gnc_sql_add_columns_to_table( GncSqlBackend* be, const gchar* table_name,
|
||||
const GncSqlColumnTableEntry* new_col_table );
|
||||
const GncSqlColumnTableEntry* new_col_table );
|
||||
|
||||
/**
|
||||
* Specifies the load order for a set of objects. When loading from a database, the
|
||||
|
@ -46,7 +46,8 @@
|
||||
#define TABLE_NAME "slots"
|
||||
#define TABLE_VERSION 3
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
FRAME,
|
||||
LIST
|
||||
} context_t;
|
||||
@ -54,14 +55,17 @@ typedef enum {
|
||||
typedef struct
|
||||
{
|
||||
/*@ dependent @*/ GncSqlBackend* be;
|
||||
/*@ dependent @*/ const GncGUID* guid;
|
||||
gboolean is_ok;
|
||||
/*@ dependent @*/ KvpFrame* pKvpFrame;
|
||||
KvpValueType value_type;
|
||||
GList *pList;
|
||||
context_t context;
|
||||
/*@ dependent @*/ KvpValue* pKvpValue;
|
||||
GString* path;
|
||||
/*@ dependent @*/
|
||||
const GncGUID* guid;
|
||||
gboolean is_ok;
|
||||
/*@ dependent @*/
|
||||
KvpFrame* pKvpFrame;
|
||||
KvpValueType value_type;
|
||||
GList *pList;
|
||||
context_t context;
|
||||
/*@ dependent @*/
|
||||
KvpValue* pKvpValue;
|
||||
GString* path;
|
||||
} slot_info_t;
|
||||
|
||||
|
||||
@ -93,7 +97,7 @@ static void slots_load_info( slot_info_t *pInfo );
|
||||
|
||||
static const GncSqlColumnTableEntry col_table[] =
|
||||
{
|
||||
/* col_name, col_type, size, flags, g0bj_param_name, qof_param_name, getter, setter */
|
||||
/* col_name, col_type, size, flags, g0bj_param_name, qof_param_name, getter, setter */
|
||||
/*@ -full_init_block @*/
|
||||
{ "id", CT_INT, 0, COL_PKEY | COL_NNUL | COL_AUTOINC },
|
||||
{
|
||||
@ -169,15 +173,15 @@ get_key_from_path( GString *path )
|
||||
str = g_strdup( path->str );
|
||||
key = strrchr( str, '/');
|
||||
|
||||
/* Remove trailing /es */
|
||||
/* Remove trailing /es */
|
||||
if ( key == NULL ) return str;
|
||||
while ( str + strlen(str) - key == 1 )
|
||||
{
|
||||
*key = '\0';
|
||||
key = strrchr( str, '/' );
|
||||
*key = '\0';
|
||||
key = strrchr( str, '/' );
|
||||
}
|
||||
if ( key == NULL ) return str;
|
||||
/* Now advance key past the last intermediate / to get the post-delimiter string */
|
||||
/* Now advance key past the last intermediate / to get the post-delimiter string */
|
||||
while ( *key == '/') ++key;
|
||||
|
||||
ret = strdup( key );
|
||||
@ -276,14 +280,14 @@ set_int64_val( gpointer pObject, gint64 value )
|
||||
if ( pInfo->value_type != KVP_TYPE_GINT64 ) return;
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_gint64( pInfo->pKvpFrame, key, value );
|
||||
g_free( key );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *pValue = kvp_value_new_gint64( value );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
KvpValue *pValue = kvp_value_new_gint64( value );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,14 +318,14 @@ set_string_val( gpointer pObject, /*@ null @*/ gpointer pValue )
|
||||
if ( pInfo->value_type != KVP_TYPE_STRING || pValue == NULL ) return;
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_string( pInfo->pKvpFrame, key, (const gchar*)pValue );
|
||||
g_free( key );
|
||||
}
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *value = kvp_value_new_string( (gchar*)pValue );
|
||||
pInfo->pList = g_list_append(pInfo->pList, value);
|
||||
KvpValue *value = kvp_value_new_string( (gchar*)pValue );
|
||||
pInfo->pList = g_list_append(pInfo->pList, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,14 +358,14 @@ set_double_val( gpointer pObject, /*@ null @*/ gpointer pValue )
|
||||
if ( pInfo->value_type != KVP_TYPE_DOUBLE || pValue == NULL ) return;
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_double( pInfo->pKvpFrame, key, *(double*)pValue );
|
||||
g_free( key );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_double( pInfo->pKvpFrame, key, *(double*)pValue );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
KvpValue *value = kvp_value_new_double( *((double*)pValue) );
|
||||
pInfo->pList = g_list_append(pInfo->pList, value);
|
||||
KvpValue *value = kvp_value_new_double( *((double*)pValue) );
|
||||
pInfo->pList = g_list_append(pInfo->pList, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,14 +390,14 @@ set_timespec_val( gpointer pObject, Timespec ts )
|
||||
if ( pInfo->value_type != KVP_TYPE_TIMESPEC ) return;
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_timespec( pInfo->pKvpFrame, key, ts );
|
||||
g_free( key );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *pValue = kvp_value_new_timespec( ts );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
KvpValue *pValue = kvp_value_new_timespec( ts );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,68 +422,68 @@ static void
|
||||
set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue )
|
||||
{
|
||||
slot_info_t* pInfo = (slot_info_t*)pObject;
|
||||
|
||||
|
||||
g_return_if_fail( pObject != NULL );
|
||||
if ( pValue == NULL ) return;
|
||||
|
||||
switch ( pInfo->value_type)
|
||||
{
|
||||
case KVP_TYPE_GUID:
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_guid( pInfo->pKvpFrame, key, (GncGUID*)pValue );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *value = kvp_value_new_guid( (GncGUID*)pValue );
|
||||
pInfo->pList = g_list_append( pInfo->pList, value );
|
||||
}
|
||||
break;
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_guid( pInfo->pKvpFrame, key, (GncGUID*)pValue );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *value = kvp_value_new_guid( (GncGUID*)pValue );
|
||||
pInfo->pList = g_list_append( pInfo->pList, value );
|
||||
}
|
||||
break;
|
||||
case KVP_TYPE_GLIST:
|
||||
{
|
||||
slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue );
|
||||
kvp_value *pValue = NULL;
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue );
|
||||
kvp_value *pValue = NULL;
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
|
||||
newInfo->context = LIST;
|
||||
newInfo->context = LIST;
|
||||
|
||||
slots_load_info( newInfo );
|
||||
pValue = kvp_value_new_glist_nc( newInfo->pList );
|
||||
kvp_frame_set_slot_nc(pInfo->pKvpFrame, key, pValue);
|
||||
g_slice_free( slot_info_t, newInfo );
|
||||
g_free( key );
|
||||
break;
|
||||
slots_load_info( newInfo );
|
||||
pValue = kvp_value_new_glist_nc( newInfo->pList );
|
||||
kvp_frame_set_slot_nc(pInfo->pKvpFrame, key, pValue);
|
||||
g_slice_free( slot_info_t, newInfo );
|
||||
g_free( key );
|
||||
break;
|
||||
}
|
||||
case KVP_TYPE_FRAME:
|
||||
{
|
||||
slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ) ;
|
||||
KvpFrame *newFrame = kvp_frame_new();
|
||||
newInfo->pKvpFrame = newFrame;
|
||||
slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ) ;
|
||||
KvpFrame *newFrame = kvp_frame_new();
|
||||
newInfo->pKvpFrame = newFrame;
|
||||
|
||||
if (pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_frame_nc( pInfo->pKvpFrame, key, newFrame );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *value = kvp_value_new_frame_nc( newFrame );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
newInfo->path = g_string_assign( newInfo->path, key );
|
||||
pInfo->pList = g_list_append( pInfo->pList, value );
|
||||
g_free( key );
|
||||
newInfo->context = FRAME;
|
||||
}
|
||||
if (pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_frame_nc( pInfo->pKvpFrame, key, newFrame );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *value = kvp_value_new_frame_nc( newFrame );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
newInfo->path = g_string_assign( newInfo->path, key );
|
||||
pInfo->pList = g_list_append( pInfo->pList, value );
|
||||
g_free( key );
|
||||
newInfo->context = FRAME;
|
||||
}
|
||||
|
||||
slots_load_info ( newInfo );
|
||||
g_slice_free( slot_info_t, newInfo );
|
||||
break;
|
||||
slots_load_info ( newInfo );
|
||||
g_slice_free( slot_info_t, newInfo );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,14 +514,14 @@ set_numeric_val( gpointer pObject, gnc_numeric value )
|
||||
if ( pInfo->value_type != KVP_TYPE_NUMERIC ) return;
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_numeric( pInfo->pKvpFrame, key, value );
|
||||
g_free( key );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *pValue = kvp_value_new_numeric( value );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
KvpValue *pValue = kvp_value_new_numeric( value );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,14 +555,14 @@ set_gdate_val( gpointer pObject, GDate* value )
|
||||
if ( pInfo->context == FRAME )
|
||||
{
|
||||
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
gchar *key = get_key_from_path( pInfo->path );
|
||||
kvp_frame_set_gdate( pInfo->pKvpFrame, key, *value );
|
||||
g_free( key );
|
||||
g_free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
KvpValue *pValue = kvp_value_new_gdate( *value );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
KvpValue *pValue = kvp_value_new_gdate( *value );
|
||||
pInfo->pList = g_list_append(pInfo->pList, pValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -612,49 +616,49 @@ save_slot( const gchar* key, KvpValue* value, gpointer data )
|
||||
case KVP_TYPE_FRAME:
|
||||
{
|
||||
KvpFrame* pKvpFrame = kvp_value_get_frame( value );
|
||||
GncGUID guid = guid_new_return();
|
||||
slot_info_t *pNewInfo = slot_info_copy( pSlot_info, &guid );
|
||||
KvpValue *oldValue = pSlot_info->pKvpValue;
|
||||
pSlot_info->pKvpValue = kvp_value_new_guid( &guid );
|
||||
GncGUID guid = guid_new_return();
|
||||
slot_info_t *pNewInfo = slot_info_copy( pSlot_info, &guid );
|
||||
KvpValue *oldValue = pSlot_info->pKvpValue;
|
||||
pSlot_info->pKvpValue = kvp_value_new_guid( &guid );
|
||||
pSlot_info->is_ok = gnc_sql_do_db_operation( pSlot_info->be,
|
||||
OP_DB_INSERT, TABLE_NAME,
|
||||
TABLE_NAME, pSlot_info,
|
||||
col_table );
|
||||
g_return_if_fail( pSlot_info->is_ok );
|
||||
OP_DB_INSERT, TABLE_NAME,
|
||||
TABLE_NAME, pSlot_info,
|
||||
col_table );
|
||||
g_return_if_fail( pSlot_info->is_ok );
|
||||
kvp_frame_for_each_slot( pKvpFrame, save_slot, pNewInfo );
|
||||
kvp_value_delete( pSlot_info->pKvpValue );
|
||||
pSlot_info->pKvpValue = oldValue;
|
||||
g_slice_free( slot_info_t, pNewInfo );
|
||||
kvp_value_delete( pSlot_info->pKvpValue );
|
||||
pSlot_info->pKvpValue = oldValue;
|
||||
g_slice_free( slot_info_t, pNewInfo );
|
||||
}
|
||||
break;
|
||||
case KVP_TYPE_GLIST:
|
||||
{
|
||||
GList *cursor;
|
||||
GncGUID guid = guid_new_return();
|
||||
slot_info_t *pNewInfo = slot_info_copy( pSlot_info, &guid );
|
||||
KvpValue *oldValue = pSlot_info->pKvpValue;
|
||||
pSlot_info->pKvpValue = kvp_value_new_guid( &guid );
|
||||
GncGUID guid = guid_new_return();
|
||||
slot_info_t *pNewInfo = slot_info_copy( pSlot_info, &guid );
|
||||
KvpValue *oldValue = pSlot_info->pKvpValue;
|
||||
pSlot_info->pKvpValue = kvp_value_new_guid( &guid );
|
||||
pSlot_info->is_ok = gnc_sql_do_db_operation( pSlot_info->be,
|
||||
OP_DB_INSERT, TABLE_NAME,
|
||||
TABLE_NAME, pSlot_info,
|
||||
col_table );
|
||||
g_return_if_fail( pSlot_info->is_ok );
|
||||
for (cursor = kvp_value_get_glist(value); cursor; cursor = cursor->next)
|
||||
{
|
||||
OP_DB_INSERT, TABLE_NAME,
|
||||
TABLE_NAME, pSlot_info,
|
||||
col_table );
|
||||
g_return_if_fail( pSlot_info->is_ok );
|
||||
for (cursor = kvp_value_get_glist(value); cursor; cursor = cursor->next)
|
||||
{
|
||||
kvp_value *val = (kvp_value*)cursor->data;
|
||||
save_slot("", val, pNewInfo);
|
||||
}
|
||||
kvp_value_delete( pSlot_info->pKvpValue );
|
||||
pSlot_info->pKvpValue = oldValue;
|
||||
g_slice_free( slot_info_t, pNewInfo );
|
||||
save_slot("", val, pNewInfo);
|
||||
}
|
||||
kvp_value_delete( pSlot_info->pKvpValue );
|
||||
pSlot_info->pKvpValue = oldValue;
|
||||
g_slice_free( slot_info_t, pNewInfo );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
pSlot_info->is_ok = gnc_sql_do_db_operation( pSlot_info->be,
|
||||
OP_DB_INSERT, TABLE_NAME,
|
||||
TABLE_NAME, pSlot_info,
|
||||
col_table );
|
||||
OP_DB_INSERT, TABLE_NAME,
|
||||
TABLE_NAME, pSlot_info,
|
||||
col_table );
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -722,14 +726,14 @@ load_slot( slot_info_t *pInfo, GncSqlRow* row )
|
||||
}
|
||||
if ( slot_info->pList != pInfo->pList )
|
||||
{
|
||||
if (pInfo->pList != NULL)
|
||||
{
|
||||
PWARN("Load slot returned a different list than the original");
|
||||
}
|
||||
else
|
||||
{
|
||||
pInfo->pList = slot_info->pList;
|
||||
}
|
||||
if (pInfo->pList != NULL)
|
||||
{
|
||||
PWARN("Load slot returned a different list than the original");
|
||||
}
|
||||
else
|
||||
{
|
||||
pInfo->pList = slot_info->pList;
|
||||
}
|
||||
}
|
||||
g_slice_free( slot_info_t, slot_info );
|
||||
}
|
||||
@ -745,7 +749,7 @@ gnc_sql_slots_load( GncSqlBackend* be, QofInstance* inst )
|
||||
info.guid = qof_instance_get_guid( inst );
|
||||
info.pKvpFrame = qof_instance_get_slots( inst );
|
||||
info.context = FRAME;
|
||||
|
||||
|
||||
slots_load_info( &info );
|
||||
}
|
||||
|
||||
@ -764,8 +768,8 @@ slots_load_info ( slot_info_t *pInfo )
|
||||
|
||||
(void)guid_to_string_buff( pInfo->guid, guid_buf );
|
||||
|
||||
buf = g_strdup_printf( "SELECT * FROM %s WHERE obj_guid='%s'",
|
||||
TABLE_NAME, guid_buf );
|
||||
buf = g_strdup_printf( "SELECT * FROM %s WHERE obj_guid='%s'",
|
||||
TABLE_NAME, guid_buf );
|
||||
stmt = gnc_sql_create_statement_from_sql( pInfo->be, buf );
|
||||
g_free( buf );
|
||||
if ( stmt != NULL )
|
||||
|
@ -721,20 +721,20 @@ save_transaction( GncSqlBackend* be, Transaction* pTx, gboolean do_save_splits )
|
||||
gnc_commodity *commodity = xaccTransGetCurrency( pTx );
|
||||
// Ensure the commodity is in the db
|
||||
is_ok = gnc_sql_save_commodity( be, commodity );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Commodity save failed: Probably an invalid or missing currency";
|
||||
qof_backend_set_error( &be->be, ERR_BACKEND_DATA_CORRUPT);
|
||||
}
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Commodity save failed: Probably an invalid or missing currency";
|
||||
qof_backend_set_error( &be->be, ERR_BACKEND_DATA_CORRUPT);
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_ok )
|
||||
{
|
||||
is_ok = gnc_sql_do_db_operation( be, op, TRANSACTION_TABLE, GNC_ID_TRANS, pTx, tx_col_table );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Transaction header save failed. Check trace log for SQL errors";
|
||||
}
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Transaction header save failed. Check trace log for SQL errors";
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_ok )
|
||||
@ -744,57 +744,57 @@ save_transaction( GncSqlBackend* be, Transaction* pTx, gboolean do_save_splits )
|
||||
if ( !qof_instance_get_destroying(inst) )
|
||||
{
|
||||
is_ok = gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Slots save failed. Check trace log for SQL errors";
|
||||
}
|
||||
if ( is_ok && do_save_splits )
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Slots save failed. Check trace log for SQL errors";
|
||||
}
|
||||
if ( is_ok && do_save_splits )
|
||||
{
|
||||
is_ok = save_splits( be, guid, xaccTransGetSplitList( pTx ) );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Split save failed. Check trace log for SQL errors";
|
||||
}
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Split save failed. Check trace log for SQL errors";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is_ok = gnc_sql_slots_delete( be, guid );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Slots delete failed. Check trace log for SQL errors";
|
||||
}
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Slots delete failed. Check trace log for SQL errors";
|
||||
}
|
||||
if ( is_ok )
|
||||
{
|
||||
is_ok = delete_splits( be, pTx );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Split delete failed. Check trace log for SQL errors";
|
||||
}
|
||||
}
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = "Split delete failed. Check trace log for SQL errors";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! is_ok )
|
||||
{
|
||||
gchar *message1 = "Transaction %s dated %s in account %s not saved due to %s.%s";
|
||||
gchar *message2 = "\nDatabase may be corrupted, check your data carefully.";
|
||||
Split* split = xaccTransGetSplit( pTx, 0);
|
||||
Account *acc = xaccSplitGetAccount( split );
|
||||
/* FIXME: This needs to be implemented
|
||||
qof_error_format_secondary_text( GTK_MESSAGE_DIALOG( msg ),
|
||||
message1,
|
||||
xaccTransGetDescription( pTx ),
|
||||
qof_print_date( xaccTransGetDate( pTx ) ),
|
||||
xaccAccountGetName( acc ),
|
||||
err,
|
||||
message2 );
|
||||
*/
|
||||
PERR( "Transaction %s dated %s in account %s not saved due to %s.\n",
|
||||
xaccTransGetDescription( pTx ),
|
||||
qof_print_date( xaccTransGetDate( pTx ) ),
|
||||
xaccAccountGetName( acc ),
|
||||
err );
|
||||
}
|
||||
{
|
||||
gchar *message1 = "Transaction %s dated %s in account %s not saved due to %s.%s";
|
||||
gchar *message2 = "\nDatabase may be corrupted, check your data carefully.";
|
||||
Split* split = xaccTransGetSplit( pTx, 0);
|
||||
Account *acc = xaccSplitGetAccount( split );
|
||||
/* FIXME: This needs to be implemented
|
||||
qof_error_format_secondary_text( GTK_MESSAGE_DIALOG( msg ),
|
||||
message1,
|
||||
xaccTransGetDescription( pTx ),
|
||||
qof_print_date( xaccTransGetDate( pTx ) ),
|
||||
xaccAccountGetName( acc ),
|
||||
err,
|
||||
message2 );
|
||||
*/
|
||||
PERR( "Transaction %s dated %s in account %s not saved due to %s.\n",
|
||||
xaccTransGetDescription( pTx ),
|
||||
qof_print_date( xaccTransGetDate( pTx ) ),
|
||||
xaccAccountGetName( acc ),
|
||||
err );
|
||||
}
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ deprecated_account_currency_handler (xmlNodePtr node, gpointer act_pdata)
|
||||
gnc_commodity *ref;
|
||||
|
||||
PWARN("Account %s: Obsolete xml tag 'act:currency' will not be preserved.",
|
||||
xaccAccountGetName( pdata->account ));
|
||||
xaccAccountGetName( pdata->account ));
|
||||
ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
|
||||
DxaccAccountSetCurrency(pdata->account, ref);
|
||||
|
||||
@ -314,7 +314,7 @@ deprecated_account_currency_scu_handler (xmlNodePtr node, gpointer act_pdata)
|
||||
{
|
||||
struct account_pdata *pdata = act_pdata;
|
||||
PWARN("Account %s: Obsolete xml tag 'act:currency-scu' will not be preserved.",
|
||||
xaccAccountGetName( pdata->account ));
|
||||
xaccAccountGetName( pdata->account ));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ deprecated_account_security_handler (xmlNodePtr node, gpointer act_pdata)
|
||||
gnc_commodity *ref, *orig = xaccAccountGetCommodity(pdata->account);
|
||||
|
||||
PWARN("Account %s: Obsolete xml tag 'act:security' will not be preserved.",
|
||||
xaccAccountGetName( pdata->account ));
|
||||
xaccAccountGetName( pdata->account ));
|
||||
/* If the account has both a commodity and a security elemet, and
|
||||
the commodity is a currecny, then the commodity is probably
|
||||
wrong. In that case we want to replace it with the
|
||||
@ -334,9 +334,9 @@ deprecated_account_security_handler (xmlNodePtr node, gpointer act_pdata)
|
||||
{
|
||||
ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
|
||||
xaccAccountSetCommodity(pdata->account, ref);
|
||||
/* If the SCU was set, it was probably wrong, so zero it out
|
||||
so that the SCU handler can fix it if there's a
|
||||
security-scu element. jralls 2010-11-02 */
|
||||
/* If the SCU was set, it was probably wrong, so zero it out
|
||||
so that the SCU handler can fix it if there's a
|
||||
security-scu element. jralls 2010-11-02 */
|
||||
xaccAccountSetCommoditySCU(pdata->account, 0);
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ deprecated_account_security_scu_handler (xmlNodePtr node, gpointer act_pdata)
|
||||
gint64 val;
|
||||
|
||||
PWARN("Account %s: Obsolete xml tag 'act:security-scu' will not be preserved.",
|
||||
xaccAccountGetName( pdata->account ));
|
||||
xaccAccountGetName( pdata->account ));
|
||||
if (!xaccAccountGetCommoditySCU(pdata->account))
|
||||
{
|
||||
dom_tree_to_integer(node, &val);
|
||||
|
@ -235,7 +235,7 @@ gnc_xml_be_get_file_lock (FileBackend *be)
|
||||
static void
|
||||
xml_session_begin(QofBackend *be_start, QofSession *session,
|
||||
const char *book_id, gboolean ignore_lock,
|
||||
gboolean create, gboolean force)
|
||||
gboolean create, gboolean force)
|
||||
{
|
||||
FileBackend *be = (FileBackend*) be_start;
|
||||
|
||||
@ -812,9 +812,9 @@ gnc_xml_be_remove_old_files(FileBackend *be)
|
||||
|
||||
/* Ensure we only evaluate GnuCash related files. */
|
||||
if ( !(g_str_has_suffix(dent, ".LNK") ||
|
||||
g_str_has_suffix(dent, ".xac") /* old data file extension */ ||
|
||||
g_str_has_suffix(dent, GNC_DATAFILE_EXT) ||
|
||||
g_str_has_suffix(dent, GNC_LOGFILE_EXT)) )
|
||||
g_str_has_suffix(dent, ".xac") /* old data file extension */ ||
|
||||
g_str_has_suffix(dent, GNC_DATAFILE_EXT) ||
|
||||
g_str_has_suffix(dent, GNC_LOGFILE_EXT)) )
|
||||
continue;
|
||||
|
||||
name = g_build_filename(be->dirname, dent, (gchar*)NULL);
|
||||
@ -882,7 +882,7 @@ gnc_xml_be_remove_old_files(FileBackend *be)
|
||||
g_unlink(name);
|
||||
}
|
||||
else if ((be->file_retention_type == XML_RETAIN_DAYS) &&
|
||||
(be->file_retention_days > 0))
|
||||
(be->file_retention_days > 0))
|
||||
{
|
||||
int days;
|
||||
|
||||
|
@ -99,7 +99,7 @@ test_load_file(const char *filename)
|
||||
"qof error=%d for file [%s]",
|
||||
qof_session_get_error(session), filename);
|
||||
/* Uncomment the line below to generate corrected files */
|
||||
qof_session_save( session, NULL );
|
||||
qof_session_save( session, NULL );
|
||||
qof_session_end(session);
|
||||
}
|
||||
|
||||
|
@ -112,11 +112,11 @@ node_and_account_equal(xmlNodePtr node, Account *act)
|
||||
}
|
||||
else if (safe_strcmp((char*)mark->name, "act:commodity") == 0)
|
||||
{
|
||||
/* This is somewhat BS, because if the commodity isn't a
|
||||
currency (and therefore built in) there isn't a
|
||||
corresponding currency in the XML, skip the test. jralls
|
||||
2010-11-02 */
|
||||
if (xaccAccountGetCommodity(act) == NULL) continue;
|
||||
/* This is somewhat BS, because if the commodity isn't a
|
||||
currency (and therefore built in) there isn't a
|
||||
corresponding currency in the XML, skip the test. jralls
|
||||
2010-11-02 */
|
||||
if (xaccAccountGetCommodity(act) == NULL) continue;
|
||||
if (!equals_node_val_vs_commodity(
|
||||
mark, xaccAccountGetCommodity(act),
|
||||
gnc_account_get_book(act)))
|
||||
@ -324,7 +324,7 @@ test_generation()
|
||||
|
||||
xaccAccountSetCode(act, "");
|
||||
xaccAccountSetDescription(act, "");
|
||||
g_print("Expect a critical assert here:\n");
|
||||
g_print("Expect a critical assert here:\n");
|
||||
xaccAccountSetCommodity(act, NULL);
|
||||
|
||||
test_account(-1, act);
|
||||
|
@ -108,13 +108,13 @@ node_and_commodity_equal(xmlNodePtr node, const gnc_commodity *com)
|
||||
g_free(txt);
|
||||
}
|
||||
}
|
||||
/* Legitimate tags which we don't yet have tests */
|
||||
/* Legitimate tags which we don't yet have tests */
|
||||
else if (safe_strcmp((char*)mark->name, "cmdty:get_quotes") == 0 ||
|
||||
safe_strcmp((char*)mark->name, "cmdty:quote_source") == 0 ||
|
||||
safe_strcmp((char*)mark->name, "cmdty:quote_tz") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
safe_strcmp((char*)mark->name, "cmdty:quote_source") == 0 ||
|
||||
safe_strcmp((char*)mark->name, "cmdty:quote_tz") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "unknown node";
|
||||
|
@ -217,8 +217,8 @@ equals_node_val_vs_splits(xmlNodePtr node, const Transaction *trn)
|
||||
|
||||
if (!spl_node)
|
||||
{
|
||||
g_print( "Split GUID %s", guid_to_string(xaccSplitGetGUID(spl_mark)) );
|
||||
return "no matching split found";
|
||||
g_print( "Split GUID %s", guid_to_string(xaccSplitGetGUID(spl_mark)) );
|
||||
return "no matching split found";
|
||||
}
|
||||
|
||||
msg = equals_node_val_vs_split_internal(spl_node, spl_mark);
|
||||
@ -262,9 +262,9 @@ node_and_transaction_equal(xmlNodePtr node, Transaction *trn)
|
||||
}
|
||||
}
|
||||
|
||||
/* This test will fail for many splits where the transaction has
|
||||
* splits in different commodities -- eg, buying or selling a
|
||||
* stock. jralls 2010-11-02 */
|
||||
/* This test will fail for many splits where the transaction has
|
||||
* splits in different commodities -- eg, buying or selling a
|
||||
* stock. jralls 2010-11-02 */
|
||||
else if (safe_strcmp((char*)mark->name, "trn:currency") == 0)
|
||||
{
|
||||
#if 0
|
||||
@ -384,7 +384,7 @@ test_transaction(void)
|
||||
* account tree. */
|
||||
root = get_random_account_tree(book);
|
||||
ran_trn = get_random_transaction(book);
|
||||
new_com = get_random_commodity( book );
|
||||
new_com = get_random_commodity( book );
|
||||
if (!ran_trn)
|
||||
{
|
||||
failure_args("transaction_xml", __FILE__, __LINE__,
|
||||
@ -402,7 +402,7 @@ test_transaction(void)
|
||||
Account * a = xaccMallocAccount(book);
|
||||
|
||||
xaccAccountBeginEdit (a);
|
||||
xaccAccountSetCommodity( a, new_com );
|
||||
xaccAccountSetCommodity( a, new_com );
|
||||
xaccAccountSetCommoditySCU (a, xaccSplitGetAmount (s).denom);
|
||||
xaccAccountInsertSplit (a, s);
|
||||
xaccAccountCommitEdit (a);
|
||||
@ -470,7 +470,7 @@ test_transaction(void)
|
||||
data.com = com;
|
||||
data.value = i;
|
||||
|
||||
g_print(" There will follow a bunch of CRIT scrub errors about the account not having a commodity. There isn't an account in the XML, so of course not. Ignore the errors\n");
|
||||
g_print(" There will follow a bunch of CRIT scrub errors about the account not having a commodity. There isn't an account in the XML, so of course not. Ignore the errors\n");
|
||||
parser = gnc_transaction_sixtp_parser_create();
|
||||
|
||||
if (!gnc_xml_parse_file(parser, filename1, test_add_transaction,
|
||||
|
@ -195,7 +195,7 @@ test_bool_fcn (QofBook *book, const char *message,
|
||||
set (employee, FALSE);
|
||||
set (employee, TRUE);
|
||||
set (employee, num);
|
||||
/* Employee record should be dirty */
|
||||
/* Employee record should be dirty */
|
||||
do_test (gncEmployeeIsDirty (employee), "test dirty later");
|
||||
gncEmployeeCommitEdit (employee);
|
||||
/* Employee record should be not dirty */
|
||||
|
@ -116,7 +116,8 @@ gnc_payment_dialog_invoice_changed(PaymentWindow *pw)
|
||||
* previously selected owner, make sure the right owner is
|
||||
* selected. */
|
||||
owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (pw->invoice));
|
||||
if (pw->owner.owner.undefined == NULL || pw->owner.owner.undefined != owner->owner.undefined) {
|
||||
if (pw->owner.owner.undefined == NULL || pw->owner.owner.undefined != owner->owner.undefined)
|
||||
{
|
||||
gnc_payment_set_owner (pw, owner);
|
||||
}
|
||||
}
|
||||
@ -138,7 +139,8 @@ gnc_payment_dialog_owner_changed(PaymentWindow *pw)
|
||||
|
||||
/* The selected invoice has a different owner than the newly
|
||||
* selected owner, reset it */
|
||||
if (pw->invoice != NULL && !gncOwnerEqual(gncOwnerGetEndOwner(gncInvoiceGetOwner(pw->invoice)), &pw->owner)) {
|
||||
if (pw->invoice != NULL && !gncOwnerEqual(gncOwnerGetEndOwner(gncInvoiceGetOwner(pw->invoice)), &pw->owner))
|
||||
{
|
||||
pw->invoice = NULL;
|
||||
gnc_invoice_set_invoice(pw->invoice_choice, NULL);
|
||||
}
|
||||
|
@ -742,14 +742,14 @@ gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_d
|
||||
* interval. Make sure to check for invalid dates here: It means
|
||||
* the SX has ended. */
|
||||
while (g_date_valid(&tmpState->last_date)
|
||||
&& (g_date_compare(&tmpState->last_date, end_date) <= 0)
|
||||
&& (!xaccSchedXactionHasEndDate(sx)
|
||||
|| g_date_compare(&tmpState->last_date, xaccSchedXactionGetEndDate(sx)) <= 0)
|
||||
&& (!xaccSchedXactionHasOccurDef(sx)
|
||||
/* The >=0 (i.e. the ==) is important here, otherwise
|
||||
* we miss the last valid occurrence of a SX which is
|
||||
* limited by num_occur */
|
||||
|| tmpState->num_occur_rem >= 0))
|
||||
&& (g_date_compare(&tmpState->last_date, end_date) <= 0)
|
||||
&& (!xaccSchedXactionHasEndDate(sx)
|
||||
|| g_date_compare(&tmpState->last_date, xaccSchedXactionGetEndDate(sx)) <= 0)
|
||||
&& (!xaccSchedXactionHasOccurDef(sx)
|
||||
/* The >=0 (i.e. the ==) is important here, otherwise
|
||||
* we miss the last valid occurrence of a SX which is
|
||||
* limited by num_occur */
|
||||
|| tmpState->num_occur_rem >= 0))
|
||||
{
|
||||
++result;
|
||||
gnc_sx_incr_temporal_state (sx, tmpState);
|
||||
|
@ -958,7 +958,8 @@ xaccTransFindOldCommonCurrency (Transaction *trans, QofBook *book)
|
||||
* it, or NULL if there is no currency more common than the
|
||||
* others -- or none at all.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gnc_commodity *commodity;
|
||||
unsigned int count;
|
||||
} CommodityCount;
|
||||
@ -968,11 +969,11 @@ commodity_equal (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
CommodityCount *cc = (CommodityCount*)a;
|
||||
gnc_commodity *com = (gnc_commodity*)b;
|
||||
if ( cc == NULL || cc->commodity == NULL ||
|
||||
!GNC_IS_COMMODITY( cc->commodity ) ) return -1;
|
||||
if ( cc == NULL || cc->commodity == NULL ||
|
||||
!GNC_IS_COMMODITY( cc->commodity ) ) return -1;
|
||||
if ( com == NULL || !GNC_IS_COMMODITY( com ) ) return 1;
|
||||
if ( gnc_commodity_equal(cc->commodity, com) )
|
||||
return 0;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -981,18 +982,18 @@ commodity_compare( gconstpointer a, gconstpointer b)
|
||||
{
|
||||
CommodityCount *ca = (CommodityCount*)a, *cb = (CommodityCount*)b;
|
||||
if (ca == NULL || ca->commodity == NULL ||
|
||||
!GNC_IS_COMMODITY( ca->commodity ) )
|
||||
!GNC_IS_COMMODITY( ca->commodity ) )
|
||||
{
|
||||
if (cb == NULL || cb->commodity == NULL ||
|
||||
!GNC_IS_COMMODITY( cb->commodity ) )
|
||||
return 0;
|
||||
return -1;
|
||||
if (cb == NULL || cb->commodity == NULL ||
|
||||
!GNC_IS_COMMODITY( cb->commodity ) )
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
if (cb == NULL || cb->commodity == NULL ||
|
||||
!GNC_IS_COMMODITY( cb->commodity ) )
|
||||
return 1;
|
||||
!GNC_IS_COMMODITY( cb->commodity ) )
|
||||
return 1;
|
||||
if (ca->count == cb->count)
|
||||
return 0;
|
||||
return 0;
|
||||
return ca->count > cb->count ? 1 : -1;
|
||||
}
|
||||
|
||||
@ -1002,7 +1003,7 @@ commodity_compare( gconstpointer a, gconstpointer b)
|
||||
* aren't, because for simple buy and sell transactions it makes
|
||||
* slightly more sense for the transaction commodity to be the
|
||||
* currency -- to the extent that it makes sense for a transaction to
|
||||
* have a currency at all. jralls, 2010-11-02 */
|
||||
* have a currency at all. jralls, 2010-11-02 */
|
||||
|
||||
static gnc_commodity *
|
||||
xaccTransFindCommonCurrency (Transaction *trans, QofBook *book)
|
||||
@ -1021,33 +1022,33 @@ xaccTransFindCommonCurrency (Transaction *trans, QofBook *book)
|
||||
for (node = trans->splits; node; node = node->next)
|
||||
{
|
||||
Split *s = node->data;
|
||||
if (s == NULL || s->acc == NULL) continue;
|
||||
com_scratch = xaccAccountGetCommodity(s->acc);
|
||||
if ( comlist )
|
||||
{
|
||||
found = g_slist_find_custom(comlist, com_scratch, commodity_equal);
|
||||
}
|
||||
if (comlist == NULL || found == NULL)
|
||||
{
|
||||
CommodityCount *count = g_slice_new0(CommodityCount);
|
||||
count->commodity = com_scratch;
|
||||
count->count = ( gnc_commodity_is_currency( com_scratch ) ? 3 : 2 );
|
||||
comlist = g_slist_append(comlist, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommodityCount *count = (CommodityCount*)(found->data);
|
||||
count->count += ( gnc_commodity_is_currency( com_scratch ) ? 3 : 2 );
|
||||
}
|
||||
if (s == NULL || s->acc == NULL) continue;
|
||||
com_scratch = xaccAccountGetCommodity(s->acc);
|
||||
if ( comlist )
|
||||
{
|
||||
found = g_slist_find_custom(comlist, com_scratch, commodity_equal);
|
||||
}
|
||||
if (comlist == NULL || found == NULL)
|
||||
{
|
||||
CommodityCount *count = g_slice_new0(CommodityCount);
|
||||
count->commodity = com_scratch;
|
||||
count->count = ( gnc_commodity_is_currency( com_scratch ) ? 3 : 2 );
|
||||
comlist = g_slist_append(comlist, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommodityCount *count = (CommodityCount*)(found->data);
|
||||
count->count += ( gnc_commodity_is_currency( com_scratch ) ? 3 : 2 );
|
||||
}
|
||||
}
|
||||
found = g_slist_sort( comlist, commodity_compare);
|
||||
|
||||
if ( ((CommodityCount*)(found->data))->commodity != NULL)
|
||||
{
|
||||
return ((CommodityCount*)(found->data))->commodity;
|
||||
return ((CommodityCount*)(found->data))->commodity;
|
||||
}
|
||||
/* We didn't find a currency in the current account structure, so try
|
||||
* an old one. */
|
||||
/* We didn't find a currency in the current account structure, so try
|
||||
* an old one. */
|
||||
return xaccTransFindOldCommonCurrency( trans, book );
|
||||
}
|
||||
|
||||
@ -1136,9 +1137,9 @@ xaccTransScrubCurrency (Transaction *trans)
|
||||
* 'other' transaction, which is going to keep that
|
||||
* information. So I don't bother with that here. -- cstim,
|
||||
* 2002/11/20. */
|
||||
/* But if the commodity *isn't* a currency, then it's
|
||||
* the value that should be changed to the
|
||||
* amount. jralls, 2010-11-02 */
|
||||
/* But if the commodity *isn't* a currency, then it's
|
||||
* the value that should be changed to the
|
||||
* amount. jralls, 2010-11-02 */
|
||||
|
||||
PWARN ("Adjusted split with mismatched values, desc=\"%s\" memo=\"%s\""
|
||||
" old amount %s %s, new amount %s",
|
||||
@ -1147,14 +1148,14 @@ xaccTransScrubCurrency (Transaction *trans)
|
||||
gnc_commodity_get_mnemonic (currency),
|
||||
gnc_num_dbg_to_string (xaccSplitGetValue(sp)));
|
||||
xaccTransBeginEdit (trans);
|
||||
if ( gnc_commodity_is_currency( currency))
|
||||
{
|
||||
xaccSplitSetAmount (sp, xaccSplitGetValue(sp));
|
||||
}
|
||||
else
|
||||
{
|
||||
xaccSplitSetValue(sp, xaccSplitGetAmount(sp));
|
||||
}
|
||||
if ( gnc_commodity_is_currency( currency))
|
||||
{
|
||||
xaccSplitSetAmount (sp, xaccSplitGetValue(sp));
|
||||
}
|
||||
else
|
||||
{
|
||||
xaccSplitSetValue(sp, xaccSplitGetAmount(sp));
|
||||
}
|
||||
xaccTransCommitEdit (trans);
|
||||
}
|
||||
/*else
|
||||
|
@ -281,7 +281,8 @@ gboolean gnc_price_list_equal(PriceList *prices1, PriceList *prices2);
|
||||
typedef struct gnc_price_db_s GNCPriceDB;
|
||||
|
||||
/** return the pricedb associated with the book */
|
||||
/*@ dependent @*/ GNCPriceDB * gnc_pricedb_get_db(QofBook *book);
|
||||
/*@ dependent @*/
|
||||
GNCPriceDB * gnc_pricedb_get_db(QofBook *book);
|
||||
GNCPriceDB * gnc_collection_get_pricedb(QofCollection *col);
|
||||
|
||||
/** gnc_pricedb_destroy - destroy the given pricedb and unref all of
|
||||
|
@ -1883,9 +1883,9 @@ get_random_query(void)
|
||||
set_query_sort (q, get_random_int_in_range (1, BY_NONE));
|
||||
|
||||
qof_query_set_sort_increasing (q,
|
||||
get_random_boolean (),
|
||||
get_random_boolean (),
|
||||
get_random_boolean ());
|
||||
get_random_boolean (),
|
||||
get_random_boolean (),
|
||||
get_random_boolean ());
|
||||
|
||||
qof_query_set_max_results (q, get_random_int_in_range (-50000, 50000));
|
||||
|
||||
|
@ -726,8 +726,8 @@ gnc_post_file_open (const char * filename)
|
||||
if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN))
|
||||
{
|
||||
/* user told us to create a new database. Do it. We
|
||||
* shouldn't have to worry about locking or clobbering,
|
||||
* it's supposed to be new. */
|
||||
* shouldn't have to worry about locking or clobbering,
|
||||
* it's supposed to be new. */
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, FALSE);
|
||||
}
|
||||
}
|
||||
@ -1025,21 +1025,22 @@ gnc_file_do_export(const char * filename)
|
||||
|
||||
io_err = qof_session_get_error (new_session);
|
||||
/* If the file exists and would be clobbered, ask the user */
|
||||
if (ERR_BACKEND_STORE_EXISTS == io_err) {
|
||||
if (ERR_BACKEND_STORE_EXISTS == io_err)
|
||||
{
|
||||
const char *format = _("The file %s already exists. "
|
||||
"Are you sure you want to overwrite it?");
|
||||
|
||||
const char *name;
|
||||
if ( gnc_uri_is_file_uri ( newfile ) )
|
||||
name = gnc_uri_get_path ( newfile );
|
||||
else
|
||||
name = gnc_uri_normalize_uri ( newfile, FALSE );
|
||||
/* if user says cancel, we should break out */
|
||||
const char *name;
|
||||
if ( gnc_uri_is_file_uri ( newfile ) )
|
||||
name = gnc_uri_get_path ( newfile );
|
||||
else
|
||||
name = gnc_uri_normalize_uri ( newfile, FALSE );
|
||||
/* if user says cancel, we should break out */
|
||||
if (!gnc_verify_dialog (NULL, FALSE, format, name))
|
||||
{
|
||||
{
|
||||
return;
|
||||
}
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, TRUE);
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, TRUE);
|
||||
}
|
||||
/* if file appears to be locked, ask the user ... */
|
||||
if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
|
||||
@ -1241,27 +1242,28 @@ gnc_file_do_save_as (const char* filename)
|
||||
io_err = qof_session_get_error (new_session);
|
||||
|
||||
/* If the file exists and would be clobbered, ask the user */
|
||||
if (ERR_BACKEND_STORE_EXISTS == io_err) {
|
||||
if (ERR_BACKEND_STORE_EXISTS == io_err)
|
||||
{
|
||||
const char *format = _("The file %s already exists. "
|
||||
"Are you sure you want to overwrite it?");
|
||||
|
||||
const char *name;
|
||||
if ( gnc_uri_is_file_uri ( newfile ) )
|
||||
name = gnc_uri_get_path ( newfile );
|
||||
else
|
||||
name = gnc_uri_normalize_uri ( newfile, FALSE );
|
||||
|
||||
/* if user says cancel, we should break out */
|
||||
const char *name;
|
||||
if ( gnc_uri_is_file_uri ( newfile ) )
|
||||
name = gnc_uri_get_path ( newfile );
|
||||
else
|
||||
name = gnc_uri_normalize_uri ( newfile, FALSE );
|
||||
|
||||
/* if user says cancel, we should break out */
|
||||
if (!gnc_verify_dialog (NULL, FALSE, format, name ))
|
||||
{
|
||||
xaccLogDisable();
|
||||
xaccLogDisable();
|
||||
qof_session_destroy (new_session);
|
||||
xaccLogEnable();
|
||||
g_free (newfile);
|
||||
save_in_progress--;
|
||||
return;
|
||||
}
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, TRUE);
|
||||
qof_session_begin (new_session, newfile, FALSE, TRUE, TRUE);
|
||||
}
|
||||
/* if file appears to be locked, ask the user ... */
|
||||
else if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
|
||||
@ -1335,28 +1337,28 @@ gnc_file_do_save_as (const char* filename)
|
||||
io_err = qof_session_get_error( new_session );
|
||||
if ( ERR_BACKEND_NO_ERR != io_err )
|
||||
{
|
||||
/* Well, poop. The save failed, so the new session is invalid and we
|
||||
* need to restore the old one.
|
||||
*/
|
||||
/* Well, poop. The save failed, so the new session is invalid and we
|
||||
* need to restore the old one.
|
||||
*/
|
||||
show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE);
|
||||
qof_event_suspend();
|
||||
qof_session_swap_data( new_session, session );
|
||||
qof_session_destroy( new_session );
|
||||
new_session = NULL;
|
||||
qof_event_resume();
|
||||
qof_event_suspend();
|
||||
qof_session_swap_data( new_session, session );
|
||||
qof_session_destroy( new_session );
|
||||
new_session = NULL;
|
||||
qof_event_resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Yay! Save was successful, we can dump the old session */
|
||||
qof_event_suspend();
|
||||
gnc_clear_current_session();
|
||||
gnc_set_current_session( new_session );
|
||||
qof_event_resume();
|
||||
session = NULL;
|
||||
/* Yay! Save was successful, we can dump the old session */
|
||||
qof_event_suspend();
|
||||
gnc_clear_current_session();
|
||||
gnc_set_current_session( new_session );
|
||||
qof_event_resume();
|
||||
session = NULL;
|
||||
|
||||
xaccReopenLog();
|
||||
gnc_add_history (new_session);
|
||||
gnc_hook_run(HOOK_BOOK_SAVED, new_session);
|
||||
xaccReopenLog();
|
||||
gnc_add_history (new_session);
|
||||
gnc_hook_run(HOOK_BOOK_SAVED, new_session);
|
||||
}
|
||||
/* --------------- END CORE SESSION CODE -------------- */
|
||||
|
||||
|
@ -720,9 +720,9 @@ gnc_query_list_set_query_sort (GNCQueryList *list, gboolean new_column)
|
||||
}
|
||||
|
||||
qof_query_set_sort_increasing (list->query,
|
||||
sort_order,
|
||||
sort_order,
|
||||
sort_order);
|
||||
sort_order,
|
||||
sort_order,
|
||||
sort_order);
|
||||
|
||||
/*
|
||||
* Recompute the list. Is this really necessary? Why not just sort
|
||||
|
@ -461,7 +461,7 @@ load_to_stream( GncHtmlWebkit* self, URLType type,
|
||||
{
|
||||
gtk_main_iteration();
|
||||
}
|
||||
/* No action required: Webkit jumps to the anchor on its own. */
|
||||
/* No action required: Webkit jumps to the anchor on its own. */
|
||||
}
|
||||
|
||||
return;
|
||||
@ -863,7 +863,7 @@ impl_webkit_show_url( GncHtml* self, URLType type,
|
||||
}
|
||||
else if ( safe_strcmp( type, URL_TYPE_JUMP ) == 0 )
|
||||
{
|
||||
/* Webkit jumps to the anchor on its own */
|
||||
/* Webkit jumps to the anchor on its own */
|
||||
}
|
||||
else if ( safe_strcmp( type, URL_TYPE_SECURE ) == 0 ||
|
||||
safe_strcmp( type, URL_TYPE_HTTP ) == 0 ||
|
||||
|
@ -597,17 +597,17 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
|
||||
AB_Transaction_SetLocalCountry(ab_trans, "DE");
|
||||
|
||||
|
||||
switch(AB_Transaction_GetType(ab_trans))
|
||||
switch (AB_Transaction_GetType(ab_trans))
|
||||
{
|
||||
case AB_Transaction_TypeDebitNote:
|
||||
case AB_Transaction_TypeDebitNote:
|
||||
trans_type = SINGLE_DEBITNOTE;
|
||||
break;
|
||||
case AB_Transaction_TypeTransaction:
|
||||
case AB_Transaction_TypeTransaction:
|
||||
/* trans_type = SINGLE_INTERNAL_TRANSFER;
|
||||
* break; */
|
||||
case AB_Transaction_TypeEuTransfer:
|
||||
case AB_Transaction_TypeTransfer:
|
||||
default:
|
||||
case AB_Transaction_TypeEuTransfer:
|
||||
case AB_Transaction_TypeTransfer:
|
||||
default:
|
||||
trans_type = SINGLE_TRANSFER;
|
||||
} /* switch */
|
||||
|
||||
@ -618,7 +618,7 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
|
||||
#ifndef AQBANKING_VERSION_5_PLUS
|
||||
, 0
|
||||
#endif
|
||||
))
|
||||
))
|
||||
{
|
||||
/* Oops, no job, probably not supported by bank */
|
||||
if (gnc_verify_dialog(
|
||||
|
@ -299,7 +299,7 @@ struct QofBackend_s
|
||||
const char *book_id,
|
||||
gboolean ignore_lock,
|
||||
gboolean create,
|
||||
gboolean force);
|
||||
gboolean force);
|
||||
void (*session_end) (QofBackend *);
|
||||
void (*destroy_backend) (/*@ only @*/ QofBackend *);
|
||||
|
||||
|
@ -149,7 +149,7 @@ void qof_session_swap_data (QofSession *session_1, QofSession *session_2);
|
||||
*/
|
||||
void qof_session_begin (QofSession *session, const char * book_id,
|
||||
gboolean ignore_lock, gboolean create,
|
||||
gboolean force);
|
||||
gboolean force);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -201,7 +201,7 @@ gnc_style_sheet_new (StyleSheetDialog * ssd)
|
||||
{
|
||||
SCM t = SCM_CAR(templates);
|
||||
const char* orig_name = scm_to_locale_string(scm_call_1(t_name, t));
|
||||
|
||||
|
||||
/* Store the untranslated names for lookup later */
|
||||
template_names = g_list_prepend (template_names, (gpointer)orig_name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user