~siretart/gnucash/ubuntu-fullsource

« back to all changes in this revision

Viewing changes to src/engine/gnc-session.c

  • Committer: Reinhard Tartler
  • Date: 2008-08-03 07:25:46 UTC
  • Revision ID: siretart@tauware.de-20080803072546-y6p8xda8zpfi62ys
import gnucash_2.2.4.orig.tar.gz

The original tarball had the md5sum: 27e660297dc5b8ce574515779d05a5a5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * gnc-session.c -- GnuCash's session handling
 
3
 *
 
4
 * Copyright (C) 2006 Chris Shoemaker <c.shoemaker@cox.net>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License as
 
8
 * published by the Free Software Foundation; either version 2 of
 
9
 * the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, contact:
 
18
 *
 
19
 * Free Software Foundation           Voice:  +1-617-542-5942
 
20
 * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
 
21
 * Boston, MA  02110-1301,  USA       gnu@gnu.org
 
22
 */
 
23
 
 
24
#include "config.h"
 
25
#include "qof.h"
 
26
#include "gnc-session.h"
 
27
#include "gnc-engine.h"
 
28
#include "TransLog.h"
 
29
 
 
30
static QofSession * current_session = NULL;
 
31
static QofLogModule log_module = GNC_MOD_ENGINE;
 
32
 
 
33
QofSession *
 
34
gnc_get_current_session (void)
 
35
{
 
36
    if (!current_session) {
 
37
        qof_event_suspend();
 
38
        current_session = qof_session_new ();
 
39
        qof_event_resume();
 
40
    }
 
41
    
 
42
    return current_session;
 
43
}
 
44
 
 
45
gboolean
 
46
gnc_current_session_exist(void)
 
47
{
 
48
    return (current_session != NULL);
 
49
}
 
50
 
 
51
void
 
52
gnc_set_current_session (QofSession *session)
 
53
{
 
54
    if (current_session)
 
55
        PINFO("Leak of current session.");
 
56
    current_session = session;
 
57
}
 
58
 
 
59
void gnc_clear_current_session()
 
60
{
 
61
    if (current_session) {
 
62
        xaccLogDisable();
 
63
        qof_session_destroy(current_session);
 
64
        xaccLogEnable();
 
65
        current_session = NULL;
 
66
    }
 
67
}