GnuCash 2.4.99
Data Structures | Functions | Variables
qofsession.c File Reference

Encapsulate a connection to a storage backend. More...

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <glib.h>
#include "qof.h"
#include "qofbackend-p.h"
#include "qofbook-p.h"
#include "qofsession-p.h"
#include "qofobject-p.h"

Go to the source code of this file.

Data Structures

struct  recurse_s
struct  backend_providers

Functions

GHookList * get_session_closed_hooks (void)
GSList * get_provider_list (void)
gboolean get_qof_providers_initialized (void)
void unregister_all_providers (void)
void qof_backend_register_provider (QofBackendProvider *prov)
GList * qof_backend_get_registered_access_method_list (void)
void qof_session_add_close_hook (GFunc fn, gpointer data)
void qof_session_call_close_hooks (QofSession *session)
void qof_session_push_error (QofSession *session, QofBackendError err, const char *message)
QofBackendError qof_session_get_error (QofSession *session)
const char * qof_session_get_error_message (const QofSession *session)
QofBackendError qof_session_pop_error (QofSession *session)
QofSessionqof_session_new (void)
QofBookqof_session_get_book (const QofSession *session)
QofBackendqof_session_get_backend (const QofSession *session)
const char * qof_session_get_file_path (const QofSession *session)
const char * qof_session_get_url (const QofSession *session)
void qof_session_ensure_all_data_loaded (QofSession *session)
void qof_session_begin (QofSession *session, const char *book_id, gboolean ignore_lock, gboolean create, gboolean force)
void qof_session_load (QofSession *session, QofPercentageFunc percentage_func)
void qof_session_save (QofSession *session, QofPercentageFunc percentage_func)
void qof_session_safe_save (QofSession *session, QofPercentageFunc percentage_func)
gboolean qof_session_save_in_progress (const QofSession *session)
void qof_session_end (QofSession *session)
void qof_session_destroy (QofSession *session)
void qof_session_swap_data (QofSession *session_1, QofSession *session_2)
gboolean qof_session_events_pending (const QofSession *session)
gboolean qof_session_process_events (QofSession *session)
gboolean qof_session_export (QofSession *tmp_session, QofSession *real_session, QofPercentageFunc percentage_func)
void init_static_qofsession_pointers (void)

Variables

void(* p_qof_session_load_backend )(QofSession *session, const char *access_method)
void(* p_qof_session_clear_error )(QofSession *session)
void(* p_qof_session_destroy_backend )(QofSession *session)

Detailed Description

Encapsulate a connection to a storage backend.

HISTORY: Created by Linas Vepstas December 1998

Author:
Copyright (c) 1998-2004 Linas Vepstas <linas@linas.org>
Copyright (c) 2000 Dave Peticolas
Copyright (c) 2005 Neil Williams <linux@codehelp.co.uk>

Definition in file qofsession.c.


Function Documentation

GList* qof_backend_get_registered_access_method_list ( void  )

Return a list of strings for the registered access methods. The owner is responsible for freeing the list but not the strings.

Definition at line 108 of file qofsession.c.

{
    GList* list = NULL;
    GSList* node;

    for ( node = provider_list; node != NULL; node = node->next )
    {
        QofBackendProvider *prov = node->data;
        list = g_list_append( list, (gchar*)prov->access_method );
    }

    return list;
}
void qof_session_add_close_hook ( GFunc  fn,
gpointer  data 
)

Register a function to be called just before a session is closed.

Parameters:
fnThe function to be called. The function definition must be func(gpointer session, gpointer user_data);
dataThe data to be passed to the function.

Definition at line 127 of file qofsession.c.

{
    GHook *hook;

    if (session_closed_hooks == NULL)
    {
        session_closed_hooks = malloc(sizeof(GHookList)); /* LEAKED */
        g_hook_list_init (session_closed_hooks, sizeof(GHook));
    }

    hook = g_hook_alloc(session_closed_hooks);
    if (!hook)
        return;

    hook->func = (GHookFunc)fn;
    hook->data = data;
    g_hook_append(session_closed_hooks, hook);
}
void qof_session_call_close_hooks ( QofSession session)

Call all registered session close hooks, informing them that the specified session is about to be closed.

Parameters:
sessionA pointer to the session being closed.

Definition at line 147 of file qofsession.c.

{
    GHook *hook;
    GFunc fn;

    if (session_closed_hooks == NULL)
        return;

    hook = g_hook_first_valid (session_closed_hooks, FALSE);
    while (hook)
    {
        fn = (GFunc)hook->func;
        fn(session, hook->data);
        hook = g_hook_next_valid (session_closed_hooks, hook, FALSE);
    }
}
void qof_session_ensure_all_data_loaded ( QofSession session)

Ensure all of the data is loaded from the session.

Definition at line 312 of file qofsession.c.

{
    QofBackend* backend;

    if (session == NULL) return;
    backend = qof_session_get_backend(session);
    if (backend == NULL) return;

    if (backend->load == NULL) return;
    backend->load(backend, qof_session_get_book(session), LOAD_TYPE_LOAD_ALL);
    qof_session_push_error (session, qof_backend_get_error(backend), NULL);
}
gboolean qof_session_events_pending ( const QofSession session)

The qof_session_events_pending() method will return TRUE if the backend has pending events which must be processed to bring the engine up to date with the backend.

Definition at line 1568 of file qofsession.c.

{
    if (!session) return FALSE;
    if (!session->backend) return FALSE;
    if (!session->backend->events_pending) return FALSE;

    return session->backend->events_pending (session->backend);
}
gboolean qof_session_process_events ( QofSession session)

The qof_session_process_events() method will process any events indicated by the qof_session_events_pending() method. It returns TRUE if the engine was modified while engine events were suspended.

Definition at line 1578 of file qofsession.c.

{
    if (!session) return FALSE;
    if (!session->backend) return FALSE;
    if (!session->backend->process_events) return FALSE;

    return session->backend->process_events (session->backend);
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines