misc cleanup

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6464 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2002-01-02 02:26:02 +00:00
parent fe06d38842
commit 72a17bc35d
5 changed files with 44 additions and 38 deletions

View File

@ -128,17 +128,24 @@ GNCBook * gnc_book_close_period (GNCBook *, Timespec,
*/ */
void gnc_book_partition (GNCBook *dest, GNCBook *src, Query *); void gnc_book_partition (GNCBook *dest, GNCBook *src, Query *);
/* The gnc_book_insert_trans() routine takes an existing transaction /* The gnc_book_insert_trans_clobber() routine takes an existing
* that is located in one book, and moves it to another book. * transaction that is located in one book, and moves it to
* It moves all of the splits as well. In the course of the * another book. It moves all of the splits as well. In the
* move, the transaction is literally deleted from the first * course of the move, the transaction is literally deleted
* book as its placed into the second. The transaction and * from the first book as its placed into the second. The
* split GUID's are not changed in the move. This routine * transaction and split GUID's are not changed in the move.
* assumes that twin accounts already exist in both books * This routine assumes that twin accounts already exist in
* (and can be located with the standard twining proceedure). * both books (and can be located with the standard twining
* proceedure).
*
* The gnc_book_insert_trans() routine does the same as the above,
* except that it doesn't actually clobber the transaction: it
* merely moves the transaction and split GUID's to the new
* books' entity tables, and not much else.
*/ */
void gnc_book_insert_trans (GNCBook *book, Transaction *trans); void gnc_book_insert_trans (GNCBook *book, Transaction *trans);
void gnc_book_insert_trans_clobber (GNCBook *book, Transaction *trans);
#endif /* XACC_PERIOD_H */ #endif /* XACC_PERIOD_H */

View File

@ -243,11 +243,12 @@ gnc_session_load_backend(GNCSession * session, char * backend_name)
LEAVE (" "); LEAVE (" ");
} }
gboolean void
gnc_session_begin (GNCSession *session, const char * book_id, gnc_session_begin (GNCSession *session, const char * book_id,
gboolean ignore_lock, gboolean create_if_nonexistent) gboolean ignore_lock, gboolean create_if_nonexistent)
{ {
if (!session) return FALSE; if (!session) return;
ENTER (" sess=%p book=%p ignore_lock=%d, book-id=%s", ENTER (" sess=%p book=%p ignore_lock=%d, book-id=%s",
session, session->book, ignore_lock, session, session->book, ignore_lock,
book_id ? book_id : "(null)"); book_id ? book_id : "(null)");
@ -260,7 +261,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
{ {
gnc_session_push_error (session, ERR_BACKEND_LOCKED, NULL); gnc_session_push_error (session, ERR_BACKEND_LOCKED, NULL);
LEAVE("bad book url"); LEAVE("bad book url");
return FALSE; return;
} }
/* seriously invalid */ /* seriously invalid */
@ -268,7 +269,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
{ {
gnc_session_push_error (session, ERR_BACKEND_NO_BACKEND, NULL); gnc_session_push_error (session, ERR_BACKEND_NO_BACKEND, NULL);
LEAVE("bad book_id"); LEAVE("bad book_id");
return FALSE; return;
} }
/* Store the sessionid URL */ /* Store the sessionid URL */
session->book_id = g_strdup (book_id); session->book_id = g_strdup (book_id);
@ -278,7 +279,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
{ {
gnc_session_push_error (session, ERR_FILEIO_FILE_NOT_FOUND, NULL); gnc_session_push_error (session, ERR_FILEIO_FILE_NOT_FOUND, NULL);
LEAVE("bad fullpath"); LEAVE("bad fullpath");
return FALSE; /* ouch */ return;
} }
PINFO ("filepath=%s", session->fullpath ? session->fullpath : "(null)"); PINFO ("filepath=%s", session->fullpath ? session->fullpath : "(null)");
@ -341,25 +342,24 @@ gnc_session_begin (GNCSession *session, const char * book_id,
session->book_id = NULL; session->book_id = NULL;
gnc_session_push_error (session, err, NULL); gnc_session_push_error (session, err, NULL);
LEAVE("backend error %d", err); LEAVE("backend error %d", err);
return FALSE; return;
} }
} }
LEAVE (" sess=%p book=%p book-id=%s", LEAVE (" sess=%p book=%p book-id=%s",
session, session->book, session, session->book,
book_id ? book_id : "(null)"); book_id ? book_id : "(null)");
return TRUE;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
gboolean void
gnc_session_load (GNCSession *session) gnc_session_load (GNCSession *session)
{ {
GNCBook *oldbook; GNCBook *oldbook;
Backend *be; Backend *be;
if (!session) return FALSE; if (!session) return;
if (!gnc_session_get_url(session)) return FALSE; if (!gnc_session_get_url(session)) return;
ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session) ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session)
? gnc_session_get_url(session) : "(null)"); ? gnc_session_get_url(session) : "(null)");
@ -419,20 +419,20 @@ gnc_session_load (GNCSession *session)
{ {
/* ?? should we restore the oldbook here ?? */ /* ?? should we restore the oldbook here ?? */
LEAVE("topgroup NULL"); LEAVE("topgroup NULL");
return FALSE; return;
} }
if (!gnc_book_get_pricedb (session->book)) if (!gnc_book_get_pricedb (session->book))
{ {
/* ?? should we restore the oldbook here ?? */ /* ?? should we restore the oldbook here ?? */
LEAVE("pricedb NULL"); LEAVE("pricedb NULL");
return FALSE; return;
} }
if (gnc_session_get_error(session) != ERR_BACKEND_NO_ERR) if (gnc_session_get_error(session) != ERR_BACKEND_NO_ERR)
{ {
LEAVE("error from backend %d", gnc_session_get_error(session)); LEAVE("error from backend %d", gnc_session_get_error(session));
return FALSE; return;
} }
xaccLogDisable(); xaccLogDisable();
@ -442,8 +442,6 @@ gnc_session_load (GNCSession *session)
LEAVE ("sess = %p, book_id=%s", session, gnc_session_get_url(session) LEAVE ("sess = %p, book_id=%s", session, gnc_session_get_url(session)
? gnc_session_get_url(session) : "(null)"); ? gnc_session_get_url(session) : "(null)");
return TRUE;
} }
gboolean gboolean

View File

@ -105,33 +105,32 @@ void gnc_session_swap_data (GNCSession *session_1, GNCSession *session_2);
* If set to FALSE, then file/database-global locks will be tested and * If set to FALSE, then file/database-global locks will be tested and
* obeyed. * obeyed.
* *
* If the datastore exists, can be reached (e.g over the net), connected * If the datastore exists, can be reached (e.g over the net),
* to, opened and read, and a lock can be obtained then a lock will be * connected to, opened and read, and a lock can be obtained then
* obtained and the function returns TRUE. Note that multi-user * a lock will be obtained. Note that multi-user datastores
* datastores (e.g. the SQL backend) typically will not need to get a * (e.g. the SQL backend) typically will not need to get a global
* global lock, and thus, the user will not be locked out. That's the * lock, and thus, the user will not be locked out. That's the
* whole point of 'multi-user'. * whole point of 'multi-user'.
* *
* If the file/database doesn't exist, and the create_if_nonexistent * If the file/database doesn't exist, and the create_if_nonexistent
* flag is set to TRUE, then the database is created. * flag is set to TRUE, then the database is created.
* *
* Otherwise the function returns FALSE. * If an error occurs, it will be pushed onto the session error
* stack, and that is where it should be examined.
*/ */
gboolean gnc_session_begin (GNCSession *session, const char * book_id, void gnc_session_begin (GNCSession *session, const char * book_id,
gboolean ignore_lock, gboolean create_if_nonexistent); gboolean ignore_lock, gboolean create_if_nonexistent);
/* The gnc_session_load() method causes the GNCBook to be made ready to /*
* The gnc_session_load() method causes the GNCBook to be made ready to
* to use with this URL/datastore. When the URL points at a file, * to use with this URL/datastore. When the URL points at a file,
* then this routine would load the data from the file. With remote * then this routine would load the data from the file. With remote
* backends, e.g. network or SQL, this would load only enough data * backends, e.g. network or SQL, this would load only enough data
* to make teh book actually usable; it would not cause *all* of the * to make teh book actually usable; it would not cause *all* of the
* data to be loaded. * data to be loaded.
*
* The function returns TRUE on success.
* (Hack alert ... what does failure mean ???)
*/ */
gboolean gnc_session_load (GNCSession *session); void gnc_session_load (GNCSession *session);
/* The gnc_session_get_error() routine can be used to obtain the reason /* The gnc_session_get_error() routine can be used to obtain the reason
* for any failure. Calling this routine returns the current error. * for any failure. Calling this routine returns the current error.

View File

@ -1584,7 +1584,7 @@ when no longer needed.")
(gw:wrap-function (gw:wrap-function
mod mod
'gnc:session-begin 'gnc:session-begin
'<gw:bool> '<gw:void>
"gnc_session_begin" "gnc_session_begin"
'((<gnc:Session*> session) '((<gnc:Session*> session)
((<gw:m-chars-caller-owned> gw:const) id) ((<gw:m-chars-caller-owned> gw:const) id)
@ -1595,7 +1595,7 @@ when no longer needed.")
(gw:wrap-function (gw:wrap-function
mod mod
'gnc:session-load 'gnc:session-load
'<gw:bool> '<gw:void>
"gnc_session_load" "gnc_session_load"
'((<gnc:Session*> session)) '((<gnc:Session*> session))
"Load the data associated with the given session.") "Load the data associated with the given session.")

View File

@ -1,5 +1,7 @@
/* test file created by Linas Vepstas <linas@linas.org> /* Test file created by Linas Vepstas <linas@linas.org>
* Minimal test to see if a book can be split into two periods
* without crashing.
* December 2001 * December 2001
* License: GPL * License: GPL
*/ */