예제 #1
0
static inline void addObj (GncBillTerm *term)
{
    struct _book_info *bi;
    bi = qof_book_get_data (qof_instance_get_book(term), _GNC_MOD_NAME);
    bi->terms = g_list_insert_sorted (bi->terms, term,
                                      (GCompareFunc)gncBillTermCompare);
}
예제 #2
0
파일: gncTaxTable.c 프로젝트: mlq/gnucash
static inline void addObj (GncTaxTable *table)
{
    struct _book_info *bi;
    bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
    bi->tables = g_list_insert_sorted (bi->tables, table,
                                       (GCompareFunc)gncTaxTableCompare);
}
예제 #3
0
static inline void maybe_resort_list (GncBillTerm *term)
{
    struct _book_info *bi;

    if (term->parent || term->invisible) return;
    bi = qof_book_get_data (qof_instance_get_book(term), _GNC_MOD_NAME);
    bi->terms = g_list_sort (bi->terms, (GCompareFunc)gncBillTermCompare);
}
예제 #4
0
GList * gncBillTermGetTerms (QofBook *book)
{
    struct _book_info *bi;
    if (!book) return NULL;

    bi = qof_book_get_data (book, _GNC_MOD_NAME);
    return bi->terms;
}
예제 #5
0
파일: gncTaxTable.c 프로젝트: mlq/gnucash
GList * gncTaxTableGetTables (QofBook *book)
{
    struct _book_info *bi;
    if (!book) return NULL;

    bi = qof_book_get_data (book, _GNC_MOD_NAME);
    return bi->tables;
}
예제 #6
0
파일: gncTaxTable.c 프로젝트: mlq/gnucash
static inline void
maybe_resort_list (GncTaxTable *table)
{
    struct _book_info *bi;

    if (table->parent || table->invisible) return;
    bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
    bi->tables = g_list_sort (bi->tables, (GCompareFunc)gncTaxTableCompare);
}
예제 #7
0
파일: gncTaxTable.c 프로젝트: mlq/gnucash
void gncTaxTableMakeInvisible (GncTaxTable *table)
{
    struct _book_info *bi;
    if (!table) return;
    gncTaxTableBeginEdit (table);
    table->invisible = TRUE;
    bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
    bi->tables = g_list_remove (bi->tables, table);
    gncTaxTableCommitEdit (table);
}
예제 #8
0
static void _gncBillTermDestroy (QofBook *book)
{
    struct _book_info *bi;

    if (!book) return;

    bi = qof_book_get_data (book, _GNC_MOD_NAME);

    g_list_free (bi->terms);
    g_free (bi);
}
예제 #9
0
/** \brief Adds a new reference to the partial book data hash.

Retrieves any existing reference list and appends the new reference.

If the book is not already marked as partial, it will be marked as
partial.
*/
static void
qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference)
{
    QofBook  *book;
    GList    *book_ref_list;

    book = qof_session_get_book(session);
    book_ref_list = (GList*)qof_book_get_data(book, ENTITYREFERENCE);
    book_ref_list = g_list_append(book_ref_list, reference);
    qof_book_set_data(book, ENTITYREFERENCE, book_ref_list);
    qof_book_set_partial(book);
}
예제 #10
0
static void
qof_book_set_partial(QofBook *book)
{
    gboolean partial;

    partial =
        (gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
    if (!partial)
    {
        qof_book_set_data(book, PARTIAL_QOFBOOK, GINT_TO_POINTER(TRUE));
    }
}
예제 #11
0
QuickFill * gnc_get_shared_address_addr4_quickfill (QofBook *book, const char * key)
{
    AddressQF *qfb;

    g_assert(book);
    g_assert(key);

    qfb = qof_book_get_data (book, key);

    if (!qfb)
    {
        qfb = build_shared_quickfill(book, key);
    }

    return qfb->qf_addr4;
}
QuickFill * gnc_get_shared_entry_desc_quickfill (QofBook *book,
        const char * key, gboolean use_invoices)
{
    EntryQF *qfb;

    g_assert(book);
    g_assert(key);

    qfb = qof_book_get_data (book, key);

    if (!qfb)
    {
        qfb = build_shared_quickfill(book, key, use_invoices);
    }

    g_assert(use_invoices == qfb->using_invoices);
    return qfb->qf;
}
예제 #13
0
void
qof_session_save (QofSession *session,
                  QofPercentageFunc percentage_func)
{
    GList *node;
    QofBackend *be;
    gboolean partial, change_backend;
    QofBackendProvider *prov;
    GSList *p;
    QofBook *book, *abook;
    int err;
    gint num;
    char *msg = NULL;
    char *book_id;

    if (!session) return;
    if (!g_atomic_int_dec_and_test(&session->lock))
        goto leave;
    ENTER ("sess=%p book_id=%s",
           session, session->book_id ? session->book_id : "(null)");
    /* Partial book handling. */
    book = qof_session_get_book(session);
    partial = (gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
    change_backend = FALSE;
    msg = g_strdup_printf(" ");
    book_id = g_strdup(session->book_id);
    if (partial == TRUE)
    {
        if (session->backend && session->backend->provider)
        {
            prov = session->backend->provider;
            if (TRUE == prov->partial_book_supported)
            {
                /* if current backend supports partial, leave alone. */
                change_backend = FALSE;
            }
            else
            {
                change_backend = TRUE;
            }
        }
        /* If provider is undefined, assume partial not supported. */
        else
        {
            change_backend = TRUE;
        }
    }
    if (change_backend == TRUE)
    {
        qof_session_destroy_backend(session);
        if (!qof_providers_initialized)
        {
            qof_providers_initialized = TRUE;
        }
        p = provider_list;
        while (p != NULL)
        {
            prov = p->data;
            if (TRUE == prov->partial_book_supported)
            {
                /** \todo check the access_method too, not in scope here, yet. */
                /*	if((TRUE == prov->partial_book_supported) &&
                (0 == g_ascii_strcasecmp (access_method, prov->access_method)))
                {*/
                if (NULL == prov->backend_new) continue;
                /* Use the providers creation callback */
                session->backend = (*(prov->backend_new))();
                session->backend->provider = prov;
                if (session->backend->session_begin)
                {
                    /* Call begin - backend has been changed,
                       so make sure a file can be written,
                       use ignore_lock and force create */
                    g_free(session->book_id);
                    session->book_id = NULL;
                    (session->backend->session_begin)(session->backend, session,
                                                      book_id, TRUE, TRUE, TRUE);
                    PINFO("Done running session_begin on changed backend");
                    err = qof_backend_get_error(session->backend);
                    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);
                        LEAVE("changed backend error %d", err);
                        goto leave;
                    }
                    if (msg != NULL)
                    {
                        PWARN("%s", msg);
                        g_free(msg);
                        msg = NULL;
                    }
                }
                /* Tell the books about the backend that they'll be using. */
                for (node = session->books; node; node = node->next)
                {
                    book = node->data;
                    qof_book_set_backend (book, session->backend);
                }
                p = NULL;
            }
            if (p)
            {
                p = p->next;
            }
        }
        if (!session->backend)
        {
            if (ERR_BACKEND_NO_ERR != qof_session_get_error(session))
            {
                msg = g_strdup_printf("failed to load backend");
                qof_session_push_error(session, ERR_BACKEND_NO_HANDLER, msg);
            }
            goto leave;
        }
    }
    /* If there is a backend, and the backend is reachable
    * (i.e. we can communicate with it), then synchronize with
    * the backend.  If we cannot contact the backend (e.g.
    * because we've gone offline, the network has crashed, etc.)
    * then give the user the option to save to the local disk.
    *
    * hack alert -- FIXME -- XXX the code below no longer
    * does what the words above say.  This needs fixing.
    */
    be = session->backend;
    if (be)
    {
        for (node = session->books; node; node = node->next)
        {
            abook = node->data;
            /* if invoked as SaveAs(), then backend not yet set */
            qof_book_set_backend (abook, be);
            be->percentage = percentage_func;
            if (be->sync)
            {
                (be->sync)(be, abook);
                if (save_error_handler(be, session))
                    goto leave;
            }
        }
        /* If we got to here, then the backend saved everything
        * just fine, and we are done. So return. */
        /* Return the book_id to previous value. */
        qof_session_clear_error (session);
        LEAVE("Success");
        goto leave;
    }
    else
    {
        if (ERR_BACKEND_NO_ERR != qof_session_get_error(session))
        {
            msg = g_strdup_printf("failed to load backend");
            qof_session_push_error(session, ERR_BACKEND_NO_HANDLER, msg);
        }
    }
    LEAVE("error -- No backend!");
leave:
    if (msg != NULL) g_free(msg);
    g_atomic_int_inc(&session->lock);
    return;
}
예제 #14
0
static inline void remObj (GncBillTerm *term)
{
    struct _book_info *bi;
    bi = qof_book_get_data (qof_instance_get_book(term), _GNC_MOD_NAME);
    bi->terms = g_list_remove (bi->terms, term);
}
예제 #15
0
파일: gncTaxTable.c 프로젝트: mlq/gnucash
static inline void remObj (GncTaxTable *table)
{
    struct _book_info *bi;
    bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
    bi->tables = g_list_remove (bi->tables, table);
}