2004-09-04 Christian Stimming <stimming@tuhh.de>

* src/import-export/hbci/*.h, *.c, macros/aqbanking.m4,
	configure.in: Major change for HBCI. It is no longer based on the
	openhbci2 library but instead on the aqbanking library
	http://sf.net/projects/aqbanking which is Martin Preuss' successor
	of openhbci2. This means that now aqbanking-0.9.2 is required
	instead of any of the openhbci[2] package. Still needs more
	testing, though.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10256 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2004-09-04 12:03:31 +00:00
parent eded6e8bd2
commit d7768d2aed
29 changed files with 964 additions and 5055 deletions

View File

@@ -1,3 +1,13 @@
2004-09-04 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/*.h, *.c, macros/aqbanking.m4,
configure.in: Major change for HBCI. It is no longer based on the
openhbci2 library but instead on the aqbanking library
http://sf.net/projects/aqbanking which is Martin Preuss' successor
of openhbci2. This means that now aqbanking-0.9.2 is required
instead of any of the openhbci[2] package. Still needs more
testing, though.
2004-08-28 Derek Atkins <derek@ihtfp.com>
* src/engine/Account.c: fix xaccAccountGetBalanceAsOfDate() to properly

View File

@@ -575,8 +575,9 @@ AC_ARG_ENABLE( mt940,
fi)
if test x${MT940_DIR} = xmt940 ;
then
AC_MSG_ERROR([Sorry, MT940 support is currently broken since it depends on the hbci module with the old openhbci 0.9.x library. But the hbci module now has been ported to the new openhbci2 library. The MT940 importer needs to be ported to openhbci2 as well before this can be enabled again.])
AM_PATH_OPENHBCI(0.9.13.2)
AC_MSG_ERROR([Sorry, MT940 support is currently broken since it depended on the hbci module with the old openhbci 0.9.x library. But the hbci module now has been ported yet again, now to the aqbanking library. The MT940 importer needs to be ported to aqbanking as well before this can be enabled again -- but this probably shouldnt be too difficult.])
#AM_PATH_OPENHBCI(0.9.13.2)
AC_AQBANKING(0,9,2)
# Note: HBCI_LIBS is changed again below in the --enable-hbci
# section. So check for mt940 first and *not* the other way round!
HBCI_LIBS="${OPENHBCI_LIBS}"
@@ -597,12 +598,16 @@ AC_ARG_ENABLE( hbci,
fi)
if test x${HBCI_DIR} = xhbci ;
then
AM_PATH_OPENHBCI2(1.9.0.8)
#all_libraries="$all_libraries $OPENHBCI_LIBS"
#all_includes="$all_includes $OPENHBCI_CXXFLAGS"
#AM_PATH_OPENHBCI(0.9.13)
HBCI_LIBS="${OPENHBCI_LIBS}"
HBCI_CFLAGS="${OPENHBCI_CFLAGS}"
#AM_PATH_OPENHBCI2(1.9.0.8)
#HBCI_LIBS="${OPENHBCI_LIBS}"
#HBCI_CFLAGS="${OPENHBCI_CFLAGS}"
AC_AQBANKING(0,9,2)
if test x${have_aqbanking} != xyes;
then
AC_MSG_ERROR([Could not find aqbanking. If you use --enable-hbci, you *have* to enable aqbanking.])
fi
HBCI_LIBS="${aqbanking_libs}"
HBCI_CFLAGS="${aqbanking_includes}"
# also check for ktoblzcheck
AC_CHECK_HEADERS(ktoblzcheck.h)
@@ -1170,7 +1175,7 @@ chmod u+x ${srcdir}/src/bin/overrides/gnucash-make-guids
LIBOBJS_SEDSCRIPT="s,\.[[^.]]* ,$U&,g;s,\.[[^.]]*\$\$,$U&,"
AC_SUBST(LIBOBJS_SEDSCRIPT)
AC_OUTPUT( intl/Makefile po/Makefile.in
AC_OUTPUT( intl/Makefile po/Makefile.in
m4/Makefile
dnl # Makefiles
Makefile

View File

@@ -30,7 +30,8 @@ MACROS= \
gperf-check.m4 \
linger.m4 \
need-declaration.m4 \
openhbci.m4
openhbci.m4 \
aqbanking.m4
EXTRA_DIST=$(MACROS) gnome-common.m4 autogen.sh
MAINTAINERCLEANFILES=macros.dep

126
macros/aqbanking.m4 Normal file
View File

@@ -0,0 +1,126 @@
# $Id$
# (c) 2004 Martin Preuss<martin@libchipcard.de>
# This function checks for AqBanking
AC_DEFUN(AC_AQBANKING, [
dnl searches for aqbanking
dnl Arguments:
dnl $1: major version minimum
dnl $2: minor version minimum
dnl $3: patchlevel version minimum
dnl $4: build version minimum
dnl Returns: aqbanking_dir
dnl aqbanking_libs
dnl aqbanking_libspp
dnl aqbanking_data
dnl aqbanking_plugins
dnl aqbanking_includes
dnl have_aqbanking
if test -z "$1"; then vma="0"; else vma="$1"; fi
if test -z "$2"; then vmi="1"; else vmi="$2"; fi
if test -z "$3"; then vpl="0"; else vpl="$3"; fi
if test -z "$4"; then vbld="0"; else vbld="$4"; fi
AC_MSG_CHECKING(if aqbanking support desired)
AC_ARG_ENABLE(aqbanking,
[ --enable-aqbanking enable aqbanking support (default=yes)],
enable_aqbanking="$enableval",
enable_aqbanking="yes")
AC_MSG_RESULT($enable_aqbanking)
have_aqbanking="no"
aqbanking_dir=""
aqbanking_data=""
aqbanking_plugins=""
aqbanking_libs=""
aqbanking_libspp=""
aqbanking_includes=""
if test "$enable_aqbanking" != "no"; then
AC_MSG_CHECKING(for aqbanking)
AC_ARG_WITH(aqbanking-dir, [ --with-aqbanking-dir=DIR
uses aqbanking from given dir],
[lcc_dir="$withval"],
[lcc_dir="${prefix} \
/usr/local \
/usr \
/"])
for li in $lcc_dir; do
if test -x "$li/bin/aqbanking-config"; then
aqbanking_dir="$li";
break
fi
done
if test -z "$aqbanking_dir"; then
AC_MSG_RESULT([not found ])
AC_MSG_ERROR([
*** The library AqBanking was not found. Obtain it from
*** http://www.aquamaniac.de.
*** If it is already installed (including the -devel package),
*** you might need to specify the location with the
*** option --with-aqbanking-dir=DIR.])
else
AC_MSG_RESULT($aqbanking_dir)
AC_MSG_CHECKING(for aqbanking libs)
aqbanking_libs="`$aqbanking_dir/bin/aqbanking-config --libraries`"
AC_MSG_RESULT($aqbanking_libs)
AC_MSG_CHECKING(for aqbanking C++ libs)
aqbanking_libspp="`$aqbanking_dir/bin/aqbanking-config --libraries++`"
AC_MSG_RESULT($aqbanking_libspp)
AC_MSG_CHECKING(for aqbanking includes)
aqbanking_includes="`$aqbanking_dir/bin/aqbanking-config --includes`"
AC_MSG_RESULT($aqbanking_includes)
AC_MSG_CHECKING(for aqbanking plugins)
aqbanking_plugins="`$aqbanking_dir/bin/aqbanking-config --plugins`"
AC_MSG_RESULT($aqbanking_plugins)
AC_MSG_CHECKING(for aqbanking data)
aqbanking_data="`$aqbanking_dir/bin/aqbanking-config --data`"
AC_MSG_RESULT($aqbanking_data)
fi
AC_MSG_CHECKING(if aqbanking test desired)
AC_ARG_ENABLE(aqbanking,
[ --enable-aqbanking-test enable aqbanking-test (default=yes)],
enable_aqbanking_test="$enableval",
enable_aqbanking_test="yes")
AC_MSG_RESULT($enable_aqbanking_test)
AC_MSG_CHECKING(for AqBanking version >=$vma.$vmi.$vpl.$vbld)
if test "$enable_aqbanking_test" != "no"; then
aqbanking_versionstring="`$aqbanking_dir/bin/aqbanking-config --vstring`.`$aqbanking_dir/bin/aqbanking-config --vbuild`"
AC_MSG_RESULT([found $aqbanking_versionstring])
if test "$vma" -gt "`$aqbanking_dir/bin/aqbanking-config --vmajor`"; then
AC_MSG_ERROR([Your AqBanking version is way too old.
Please update from http://www.aquamaniac.de/aqbanking/])
elif test "$vma" = "`$aqbanking_dir/bin/aqbanking-config --vmajor`"; then
if test "$vmi" -gt "`$aqbanking_dir/bin/aqbanking-config --vminor`"; then
AC_MSG_ERROR([Your AqBanking version is too old.
Please update from http://www.aquamaniac.de/aqbanking/])
elif test "$vmi" = "`$aqbanking_dir/bin/aqbanking-config --vminor`"; then
if test "$vpl" -gt "`$aqbanking_dir/bin/aqbanking-config --vpatchlevel`"; then
AC_MSG_ERROR([Your AqBanking version is a little bit too old.
Please update from http://www.aquamaniac.de/aqbanking/])
elif test "$vpl" = "`$aqbanking_dir/bin/aqbanking-config --vpatchlevel`"; then
if test "$vbld" -gt "`$aqbanking_dir/bin/aqbanking-config --vbuild`"; then
AC_MSG_ERROR([Your AqBanking version is a little bit too old.
Please update to the latest CVS version. Instructions for accessing
CVS can be found on http://www.aquamaniac.de/aqbanking/])
fi
fi
fi
fi
have_aqbanking="yes"
#AC_MSG_RESULT(yes)
else
have_aqbanking="yes"
AC_MSG_RESULT(assuming yes)
fi
dnl end of "if enable-aqbanking"
fi
AC_SUBST(aqbanking_dir)
AC_SUBST(aqbanking_plugins)
AC_SUBST(aqbanking_libs)
AC_SUBST(aqbanking_libspp)
AC_SUBST(aqbanking_data)
AC_SUBST(aqbanking_includes)
])

View File

@@ -1,196 +0,0 @@
# Configure paths for OpenHBCI
# by Christian Stimming 2002-07-30, updated 2003-05-09
# Copied from glib-2.0.m4 by Owen Taylor 1997-2001
dnl AM_PATH_OPENHBCI2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for OPENHBCI, and define OPENHBCI_CFLAGS, OPENHBCI_CXXFLAGS and OPENHBCI_LIBS
dnl
AC_DEFUN(AM_PATH_OPENHBCI2, [
dnl
dnl Get the c[xx]flags and libraries from openhbci2-config
dnl
AC_MSG_CHECKING(for OpenHBCI)
AC_ARG_ENABLE(openhbcitest, [ --disable-openhbcitest do not try to compile and run a test OpenHBCI program],
, enable_openhbcitest=yes)
AC_ARG_WITH( openhbci-prefix,
[ --with-openhbci-prefix=PFX Prefix where OpenHBCI is installed],
OPENHBCI_PREFIX="$with_openhbci_prefix",
OPENHBCI_PREFIX="${prefix} \
/usr/local \
/usr/local/openhbci \
/usr")
hbci_config=""
for li in $OPENHBCI_PREFIX; do
if test -x "${li}/bin/openhbci2-config"; then
hbci_config="${li}/bin/openhbci2-config"
hbci_dir="${li}"
break
fi
done
if test -x "${hbci_config}" ; then
OPENHBCI_LIBS="`${hbci_config} --libraries`"
OPENHBCI_CFLAGS="`${hbci_config} --includes`"
OPENHBCI_CXXFLAGS="`${hbci_config} --includes`"
OPENHBCI_PLUGINS="`${hbci_config} --plugins`"
else
AC_MSG_ERROR([
Could not find bin/openhbci2-config in prefix ${OPENHBCI_PREFIX}.
Please specify the right path by --with-openhbci-prefix=PREFIX.
])
fi
AC_MSG_RESULT($hbci_dir)
min_openhbci_version=ifelse([$1], ,0.9.0.0,$1)
AC_MSG_CHECKING(for OpenHBCI - version >= $min_openhbci_version)
dnl AC_LANG_PUSH(C++) -- DON'T use C++ here!!!
if test "x$enable_openhbcitest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $OPENHBCI_CFLAGS"
LIBS="$OPENHBCI_LIBS $LIBS"
dnl
dnl Now check if the installed OpenHBCI is sufficiently new. (Also sanity
dnl checks the results of path guessing to some extent)
dnl
rm -f conf.openhbcitest
AC_TRY_RUN([
#include <openhbci2.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef OPENHBCI_VERSION_BUILD
# define OPENHBCI_VERSION_BUILD 0
#endif
int
main ()
{
int major, minor, micro, build;
int getmajor, getminor, getmicro, getbuild;
char *tmp_version;
system ("touch conf.openhbcitest");
/* HP/UX 9 writes to sscanf strings */
tmp_version = strdup("$min_openhbci_version");
build=0;
if (sscanf(tmp_version, "%d.%d.%d.%d", &major, &minor, &micro, &build) != 4)
{
build = 0;
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3)
{
micro = 0;
if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2)
{
minor = 0;
if (sscanf(tmp_version, "%d", &major) != 1)
{
printf("\n*** AM PATH OPENHBCI: bad version string: %s\n", "$min_openhbci_version");
exit(1);
}
}
}
}
HBCI_Hbci_libraryVersion_build(&getmajor, &getminor, &getmicro, &getbuild);
if ((getmajor != OPENHBCI_VERSION_MAJOR) ||
(getminor != OPENHBCI_VERSION_MINOR) ||
(getmicro != OPENHBCI_VERSION_PATCHLEVEL) ||
(getbuild != OPENHBCI_VERSION_BUILD))
{
printf("\n*** OpenHBCI header files openhbci2.h "
"(version %d.%d.%d build %d) do not match\n",
OPENHBCI_VERSION_MAJOR,
OPENHBCI_VERSION_MINOR,
OPENHBCI_VERSION_PATCHLEVEL,
OPENHBCI_VERSION_BUILD);
printf("*** installed library libopenhbci.so "
"(version %d.%d.%d build %d)\n",
getmajor, getminor, getmicro, getbuild);
exit(1);
}
else
{
if ((getmajor > major) ||
((getmajor == major) && (getminor > minor)) ||
((getmajor == major) && (getminor == minor) && (getmicro > micro)) ||
((getmajor == major) && (getminor == minor) &&
(getmicro == micro) && (getbuild >= build)))
{
return 0;
}
else
{
printf("\n*** An old version of OpenHBCI (%d.%d.%d build %d) was found.\n",
getmajor, getminor, getmicro, getbuild);
printf("*** You need OpenHBCI in version %d.%d.%d build %d or newer. The latest\n",
major, minor, micro, build);
printf("*** version of OpenHBCI is always available from http://www.openhbci.de.\n");
if (build > 0)
printf("*** Note: The non-zero build number '%d' indicates that the latest CVS \n"
"*** version of openhbci is required.\n", build);
printf("***\n"
"*** If you have already installed a sufficiently new version, this error\n"
"*** probably means that you need to specify the right path by\n"
"*** --with-openhbci-prefix=PATH. (Also, check that your LD_LIBRARY_PATH\n"
"*** enviroment variable is correct, or edit /etc/ld.so.conf\n"
"*** so that the correct libraries are found at run-time)\n");
}
}
return 1;
}
],, no_openhbci=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
if test "x$no_openhbci" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test -f conf.openhbcitest ; then
:
else
echo "*** Could not run OpenHBCI test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $OPENHBCI_CFLAGS"
LIBS="$LIBS $OPENHBCI_LIBS"
AC_TRY_LINK([
#include <openhbci2.h>
#include <stdio.h>
], [ return ((OPENHBCI_VERSION_MAJOR) || (OPENHBCI_VERSION_MINOR)); ],
[ echo "***"
echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding OpenHBCI or finding the wrong"
echo "*** version of OpenHBCI. If it is not finding OpenHBCI, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system."
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH."
echo "***" ],
[ echo "***"
echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means OpenHBCI is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
OPENHBCI_CFLAGS=""
OPENHBCI_LIBS=""
ifelse([$3], , :, [$3])
exit 1;
fi
AC_SUBST(OPENHBCI_CFLAGS)
AC_SUBST(OPENHBCI_LIBS)
AC_SUBST(OPENHBCI_CXXFLAGS)
AC_SUBST(OPENHBCI_PLUGINS)
dnl AC_LANG_POP(C++)
rm -f conf.openhbcitest
])

View File

@@ -3,21 +3,22 @@ SUBDIRS = . glade test
pkglib_LTLIBRARIES = libgncmod-hbci.la
libgncmod_hbci_la_SOURCES = \
gncmod-hbci.c \
druid-hbci-utils.c \
dialog-pass.c \
dialog-hbcitrans.c \
dialog-daterange.c \
gnc-hbci-account.c \
gnc-hbci-kvp.c \
gnc-hbci-utils.c \
dialog-hbcitrans.c \
dialog-pass.c \
gnc-hbci-cb.c \
gnc-hbci-transfer.c \
gnc-hbci-trans-templ.c \
gnc-hbci-getbalance.c \
gnc-hbci-gettrans.c \
gnc-hbci-kvp.c \
gnc-hbci-trans-templ.c \
gnc-hbci-transfer.c \
gnc-hbci-utils.c \
hbci-interaction.c \
druid-hbci-initial.c
druid-hbci-utils.c \
druid-hbci-initial.c \
gncmod-hbci.c
# Must be included in tarball because they are listed in POTFILES.in
libgncmod_hbci_la_empty = \
@@ -29,8 +30,6 @@ noinst_HEADERS = \
dialog-pass.h \
druid-hbci-initial.h \
druid-hbci-utils.h \
gnc-hbci-actions.h \
gnc-hbci-account.h \
gnc-hbci-cb.h \
gnc-hbci-getbalance.h \
gnc-hbci-gettrans.h \

View File

@@ -59,10 +59,10 @@ gnc_hbci_enter_daterange (GtkWidget *parent,
GtkWidget *first_button;
GtkWidget *now_button;
xml = gnc_glade_xml_new ("hbci.glade", "HBCI_daterange_dialog");
xml = gnc_glade_xml_new ("hbci.glade", "GWEN_TIMErange_dialog");
g_assert
(dialog = glade_xml_get_widget (xml, "HBCI_daterange_dialog"));
(dialog = glade_xml_get_widget (xml, "GWEN_TIMErange_dialog"));
if (parent)
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (parent));

View File

@@ -27,8 +27,8 @@
#endif
#include <gnome.h>
#include <openhbci2/bank.h>
#include <openhbci2.h>
#include <aqbanking/account.h>
#include <aqbanking/jobsingletransfer.h>
#include "dialog-utils.h"
#include "gnc-ui.h"
@@ -82,7 +82,7 @@ struct _trans_data
gboolean templ_changed;
/* The HBCI transaction that got created here */
HBCI_Transaction *hbci_trans;
AB_TRANSACTION *hbci_trans;
/* The gnucash transaction dialog where the user specifies the gnucash transaction. */
XferDialog *gnc_trans_dialog;
@@ -104,7 +104,7 @@ void gnc_hbci_dialog_delete(HBCITransDialog *td)
if (td->gnc_trans_dialog)
gnc_xfer_dialog_set_txn_cb(td->gnc_trans_dialog, NULL, NULL);
if (td->hbci_trans)
HBCI_Transaction_delete (td->hbci_trans);
AB_Transaction_free (td->hbci_trans);
td->selected_template = NULL;
@@ -124,7 +124,7 @@ GtkWidget *gnc_hbci_dialog_get_parent(const HBCITransDialog *td)
g_assert(td);
return td->parent;
}
const HBCI_Transaction *gnc_hbci_dialog_get_htrans(const HBCITransDialog *td)
const AB_TRANSACTION *gnc_hbci_dialog_get_htrans(const HBCITransDialog *td)
{
g_assert(td);
return td->hbci_trans;
@@ -155,11 +155,11 @@ void gnc_hbci_dialog_show(HBCITransDialog *td)
/* Prototypes; callbacks for dialog function */
/* -------------------------------------- */
HBCI_Transaction *
hbci_trans_fill_values(const gnc_HBCI_Account *h_acc, HBCITransDialog *td);
AB_TRANSACTION *
hbci_trans_fill_values(const AB_ACCOUNT *h_acc, HBCITransDialog *td);
gboolean
check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
const HBCI_Transaction *trans);
const AB_TRANSACTION *trans);
void on_template_list_select_child(GtkList *list, GtkWidget *widget, gpointer user_data);
void on_template_list_selection_changed(GtkList *list, gpointer user_data);
@@ -204,14 +204,13 @@ static void fill_template_list_func(gpointer data, gpointer user_data)
HBCITransDialog *
gnc_hbci_dialog_new (GtkWidget *parent,
const gnc_HBCI_Account *h_acc,
const HBCI_Customer *customer,
const AB_ACCOUNT *h_acc,
Account *gnc_acc,
GNC_HBCI_Transtype trans_type,
GList *templates)
{
GladeXML *xml;
const HBCI_Bank *bank;
const char *hbci_bankid, *hbci_bankname;
HBCITransDialog *td;
td = g_new0(HBCITransDialog, 1);
@@ -220,9 +219,8 @@ gnc_hbci_dialog_new (GtkWidget *parent,
td->templ = templates;
td->trans_type = trans_type;
g_assert (h_acc);
g_assert (customer);
bank = gnc_HBCI_Account_bank (h_acc);
g_assert (bank);
hbci_bankid = AB_Account_GetBankCode(h_acc);
hbci_bankname = AB_Account_GetBankName(h_acc);
#if HAVE_KTOBLZCHECK_H
td->blzcheck = AccountNumberCheck_new();
#endif
@@ -354,17 +352,15 @@ gnc_hbci_dialog_new (GtkWidget *parent,
/* Fill in the values from the objects */
gtk_label_set_text (GTK_LABEL (orig_name_label),
(strlen(HBCI_Customer_name (customer)) > 0 ?
HBCI_Customer_name (customer) :
HBCI_Customer_custId (customer)));
AB_Account_GetOwnerName (h_acc));
gtk_label_set_text (GTK_LABEL (orig_account_label),
gnc_HBCI_Account_accountId (h_acc));
AB_Account_GetAccountNumber (h_acc));
gtk_label_set_text (GTK_LABEL (orig_bankname_label),
(strlen(HBCI_Bank_name (bank))>0 ?
HBCI_Bank_name (bank) :
(strlen(hbci_bankname)>0 ?
hbci_bankname :
_("(unknown)")));
gtk_label_set_text (GTK_LABEL (orig_bankcode_label),
HBCI_Bank_bankCode (bank));
hbci_bankid);
/* fill list for choosing a transaction template */
g_list_foreach(td->templ, fill_template_list_func,
@@ -424,7 +420,7 @@ gnc_hbci_dialog_new (GtkWidget *parent,
*/
int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
const gnc_HBCI_Account *h_acc)
const AB_ACCOUNT *h_acc)
{
int result;
gboolean values_ok;
@@ -449,13 +445,13 @@ int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
}
/* Now fill in the values from the entry fields into a new
HBCI_Transaction. */
AB_TRANSACTION. */
td->hbci_trans = hbci_trans_fill_values(h_acc, td);
values_ok = TRUE;
/*printf("dialog-hbcitrans: Got value as %s .\n",
HBCI_Value_toReadableString (HBCI_Transaction_value (trans)));*/
if (HBCI_Value_getValue (HBCI_Transaction_value (td->hbci_trans)) == 0.0) {
AB_VALUE_toReadableString (AB_TRANSACTION_value (trans)));*/
if (AB_Value_GetValue (AB_Transaction_GetValue (td->hbci_trans)) == 0.0) {
gtk_widget_show_all (td->dialog);
values_ok = !gnc_verify_dialog
(GTK_WIDGET (td->dialog),
@@ -468,7 +464,7 @@ int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
"This does not result in a valid online transfer job.\n"
"Do you want to enter the job again?"));
if (values_ok) {
HBCI_Transaction_delete (td->hbci_trans);
AB_Transaction_free (td->hbci_trans);
return -1;
}
continue;
@@ -477,7 +473,7 @@ int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
/* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
transactionCode according to some GUI selection here!! */
/*if (td->trans_type == SINGLE_DEBITNOTE)
HBCI_Transaction_setTransactionCode (td->hbci_trans, 05);*/
AB_TRANSACTION_setTransactionCode (td->hbci_trans, 05);*/
/* And finally check the account code, if ktoblzcheck is available. */
values_ok = check_ktoblzcheck(GTK_WIDGET (td->dialog), td, td->hbci_trans);
@@ -488,62 +484,63 @@ int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
}
/** Create a new HBCI_Transaction, fill the values from the entry
/** Create a new AB_TRANSACTION, fill the values from the entry
fields into it and return it. The caller must
HBCI_Transaction_delete() it when finished. */
HBCI_Transaction *
hbci_trans_fill_values(const gnc_HBCI_Account *h_acc, HBCITransDialog *td)
AB_TRANSACTION_free() it when finished. */
AB_TRANSACTION *
hbci_trans_fill_values(const AB_ACCOUNT *h_acc, HBCITransDialog *td)
{
GWEN_DB_NODE *xnode = GWEN_DB_Group_new("transaction");
/* Fill in the user-entered values */
HBCI_Transaction *trans = HBCI_Transaction_new(xnode);
AB_TRANSACTION *trans = AB_Transaction_new();
/* OpenHBCI newer than 0.9.8: use account's bankCode values
* instead of the bank's ones since this is what some banks
* require. */
HBCI_Transaction_setOurBankCode (trans,
gnc_HBCI_Account_bankCode (h_acc));
HBCI_Transaction_setOurAccountId (trans, gnc_HBCI_Account_accountId (h_acc));
AB_Transaction_SetLocalBankCode (trans,
AB_Account_GetBankCode (h_acc));
AB_Transaction_SetLocalAccountNumber (trans, AB_Account_GetAccountNumber (h_acc));
HBCI_Transaction_setOtherBankCode
AB_Transaction_SetRemoteBankCode
(trans, gtk_entry_get_text (GTK_ENTRY (td->recp_bankcode_entry)));
/* printf("Got otherBankCode %s.\n",
HBCI_Transaction_otherBankCode (trans)); */
HBCI_Transaction_setOtherAccountId
AB_Transaction_otherBankCode (trans)); */
AB_Transaction_SetRemoteAccountNumber
(trans, gtk_entry_get_text (GTK_ENTRY (td->recp_account_entry)));
/* printf("Got otherAccountId %s.\n",
HBCI_Transaction_otherAccountId (trans)); */
HBCI_Transaction_addOtherName
(trans, gtk_entry_get_text (GTK_ENTRY (td->recp_name_entry)));
AB_Transaction_otherAccountId (trans)); */
AB_Transaction_AddRemoteName
(trans, gtk_entry_get_text (GTK_ENTRY (td->recp_name_entry)), FALSE);
HBCI_Transaction_addDescription
(trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_entry)));
HBCI_Transaction_addDescription
(trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_cont_entry)));
/* The last argument means: If TRUE, then the string will be only be
appended if it doesn't exist yet. */
AB_Transaction_AddPurpose
(trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_entry)), FALSE);
AB_Transaction_AddPurpose
(trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_cont_entry)), FALSE);
/* FIXME: Replace "EUR" by account-dependent string here. */
HBCI_Transaction_setValue
(trans, HBCI_Value_new_double
AB_Transaction_SetValue
(trans, AB_Value_new
(gnc_amount_edit_get_damount (GNC_AMOUNT_EDIT (td->amount_edit)), "EUR"));
/* If this is a direct debit, a textkey/ "Textschluessel"/
transactionCode different from the default has to be set. */
switch(td->trans_type) {
case SINGLE_DEBITNOTE:
HBCI_Transaction_setTransactionCode (trans, 05);
AB_Transaction_SetTransactionCode (trans, 05);
default:
HBCI_Transaction_setTransactionCode (trans, 51);
AB_Transaction_SetTransactionCode (trans, 51);
}
return trans;
}
/** Checks the account code in the HBCI_Transaction, if the
/** Checks the account code in the AB_TRANSACTION, if the
ktoblzcheck package is available. Returns TRUE if everything is
fine, or FALSE if this transaction should be entered again. */
gboolean
check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
const HBCI_Transaction *trans)
const AB_TRANSACTION *trans)
{
#if HAVE_KTOBLZCHECK_H
int blzresult;
@@ -552,8 +549,8 @@ check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
blzresult = AccountNumberCheck_check
(td->blzcheck,
HBCI_Transaction_otherBankCode (trans),
HBCI_Transaction_otherAccountId (trans));
AB_Transaction_GetRemoteBankCode (trans),
AB_Transaction_GetRemoteAccountNumber (trans));
switch (blzresult) {
case 2:
gtk_widget_show_all (parent);
@@ -564,8 +561,8 @@ check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
"at the specified bank with bank code '%s' failed. This means \n"
"the account number might contain an error. Should the online \n"
"transfer job be sent with this account number anyway?"),
HBCI_Transaction_otherAccountId (trans),
HBCI_Transaction_otherBankCode (trans));
AB_Transaction_GetRemoteAccountNumber (trans),
AB_Transaction_GetRemoteBankCode (trans));
blztext = "Kontonummer wahrscheinlich falsch";
break;
case 0:
@@ -588,14 +585,12 @@ check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
#endif
}
HBCI_OutboxJob *
gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api,
HBCI_Outbox *outbox,
const HBCI_Customer *customer,
gnc_HBCI_Account *h_acc,
AB_JOB *
gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, AB_BANKING *api,
AB_ACCOUNT *h_acc,
GNC_HBCI_Transtype trans_type)
{
HBCI_OutboxJob *job;
AB_JOB *job;
const char *jobname;
/* Create a Do-Transaction (Transfer) job. */
@@ -617,39 +612,36 @@ gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api,
jobname = "JobSingleTransfer";
}
}
job = HBCI_OutboxJob_new(jobname, (HBCI_Customer *)customer,
gnc_HBCI_Account_accountId(h_acc));
HBCI_Job_addRequestData(HBCI_OutboxJob_Job(job),
"", HBCI_Transaction_node(td->hbci_trans));
job = AB_JobSingleTransfer_new(h_acc);
AB_JobSingleTransfer_SetTransaction(job, td->hbci_trans);
/* Make really sure there is no other job in the queue */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
/* HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE); */
/* Add job to queue */
HBCI_Outbox_addJob(outbox, job);
AB_Banking_EnqueueJob(api, job);
return job;
}
gboolean
gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
HBCI_Outbox *outbox,
HBCI_OutboxJob *job, GNCInteractor *interactor)
gnc_hbci_trans_dialog_execute(HBCITransDialog *td, AB_BANKING *api,
AB_JOB *job, GNCInteractor *interactor)
{
gboolean successful;
g_assert(td);
g_assert(api);
g_assert(job);
successful = gnc_hbci_api_execute (td->parent, api, outbox, job, interactor);
successful = gnc_AB_BANKING_execute (td->parent, api, job, interactor);
/*printf("dialog-hbcitrans: Ok, result of api_execute was %d.\n",
successful);*/
if (!successful) {
/* HBCI_API_executeOutbox failed. */
if ((HBCI_OutboxJob_status (job) == HBCI_JOB_STATUS_DONE) &&
(HBCI_OutboxJob_result (job) == HBCI_JOB_RESULT_FAILED))
/* AB_BANKING_executeOutbox failed. */
if ((AB_Job_GetStatus (job) == AB_Job_StatusPending) ||
(AB_Job_GetStatus (job) == AB_Job_StatusError))
successful = !gnc_verify_dialog
(td->parent,
FALSE,
@@ -662,12 +654,12 @@ gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
"\n"
"Do you want to enter the job again?"));
HBCI_Transaction_delete (td->hbci_trans);
AB_Transaction_free (td->hbci_trans);
td->hbci_trans = NULL;
}
/* Watch out! The job *has* to be removed from the queue
here because otherwise it might be executed again. */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
AB_Banking_DequeueJob(api, job);
return successful;
}

View File

@@ -27,10 +27,9 @@
#include <gnome.h>
#include <openhbci2/api.h>
#include <openhbci2/customer.h>
#include <openhbci2/transaction.h>
#include <openhbci2/outboxjob.h>
#include <aqbanking/banking.h>
#include <aqbanking/transaction.h>
#include <aqbanking/job.h>
#include "Account.h"
#include "gnc-hbci-utils.h"
@@ -44,11 +43,11 @@ typedef enum GNC_HBCI_Transtype {
} GNC_HBCI_Transtype;
/*HBCI_Transaction *
/*AB_TRANSACTION *
gnc_hbci_trans (GtkWidget *parent,
HBCI_API *api,
AB_BANKING *api,
GNCInteractor *interactor,
const gnc_HBCI_Account *h_acc,
const AB_ACCOUNT *h_acc,
const HBCI_Customer *customer,
Account *gnc_acc,
GNC_HBCI_Transtype type,
@@ -58,8 +57,7 @@ gnc_hbci_trans (GtkWidget *parent,
* specified by the arguments, and return a pointer to it. */
HBCITransDialog *
gnc_hbci_dialog_new (GtkWidget *parent,
const gnc_HBCI_Account *h_acc,
const HBCI_Customer *customer,
const AB_ACCOUNT *h_acc,
Account *gnc_acc,
GNC_HBCI_Transtype trans_type,
GList *templ);
@@ -72,8 +70,8 @@ GtkWidget *gnc_hbci_dialog_get_parent(const HBCITransDialog *td);
GList *gnc_hbci_dialog_get_templ(const HBCITransDialog *td);
/** Return the change status of the template list */
gboolean gnc_hbci_dialog_get_templ_changed(const HBCITransDialog *td) ;
/** Return the HBCI_Transaction. */
const HBCI_Transaction *gnc_hbci_dialog_get_htrans(const HBCITransDialog *td);
/** Return the AB_TRANSACTION. */
const AB_TRANSACTION *gnc_hbci_dialog_get_htrans(const HBCITransDialog *td);
/** Return the gnucash Transaction. */
Transaction *gnc_hbci_dialog_get_gtrans(const HBCITransDialog *td);
/** Hide the dialog */
@@ -84,12 +82,10 @@ void gnc_hbci_dialog_show(HBCITransDialog *td);
int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
const gnc_HBCI_Account *h_acc);
HBCI_OutboxJob *
gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api,
HBCI_Outbox *outbox,
const HBCI_Customer *customer,
gnc_HBCI_Account *h_acc,
const AB_ACCOUNT *h_acc);
AB_JOB *
gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, AB_BANKING *api,
AB_ACCOUNT *h_acc,
GNC_HBCI_Transtype trans_type);
/** Callback function for gnc_xfer_dialog_set_txn_cb(). The user_data
* has to be a pointer to a HBCITransDialog structure. */
@@ -99,9 +95,8 @@ void gnc_hbci_dialog_xfer_cb(Transaction *trans, gpointer user_data);
* the application should continue, and FALSE if the user wants to
* enter this job again. */
gboolean
gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
HBCI_Outbox *outbox,
HBCI_OutboxJob *job, GNCInteractor *interactor);
gnc_hbci_trans_dialog_execute(HBCITransDialog *td, AB_BANKING *api,
AB_JOB *job, GNCInteractor *interactor);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -45,10 +45,6 @@
/* #include "gnc-gui-query.h" */
/* #include "io-example-account.h" */
/* #include "top-level.h" */
#include <openhbci2/api.h>
#include <openhbci2/outboxjob.h>
#include <openhbci2/mediumrdhbase.h>
#include <openhbci2/rsakey.h>
#include "gnc-hbci-utils.h"
@@ -58,37 +54,21 @@
static void
accounts_save_kvp_cb (gpointer key, gpointer value, gpointer user_data)
{
gnc_HBCI_Account *hbci_acc = key;
AB_ACCOUNT *hbci_acc = key;
Account *gnc_acc = value;
g_assert(hbci_acc);
g_assert(gnc_acc);
if ((gnc_hbci_get_account_accountid(gnc_acc) == NULL ) ||
(strcmp (gnc_hbci_get_account_accountid(gnc_acc),
gnc_HBCI_Account_accountId (hbci_acc)) != 0))
gnc_hbci_set_account_accountid
(gnc_acc, gnc_HBCI_Account_accountId (hbci_acc));
if ((gnc_hbci_get_account_bankcode(gnc_acc) == NULL) ||
(strcmp (gnc_hbci_get_account_bankcode(gnc_acc),
HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hbci_acc))) != 0))
gnc_hbci_set_account_bankcode
(gnc_acc, HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hbci_acc)));
if (gnc_hbci_get_account_countrycode(gnc_acc) !=
HBCI_Bank_country (gnc_HBCI_Account_bank (hbci_acc)))
gnc_hbci_set_account_countrycode
(gnc_acc, HBCI_Bank_country (gnc_HBCI_Account_bank (hbci_acc)));
if (gnc_hbci_get_account_uid(gnc_acc) !=
AB_Account_GetUniqueId(hbci_acc))
gnc_hbci_set_account_uid
(gnc_acc, AB_Account_GetUniqueId(hbci_acc));
}
static gpointer accounts_clear_kvp (Account *gnc_acc, gpointer user_data)
{
if (gnc_hbci_get_account_accountid(gnc_acc))
gnc_hbci_set_account_accountid (gnc_acc, "");
if (gnc_hbci_get_account_bankcode(gnc_acc))
gnc_hbci_set_account_bankcode (gnc_acc, "");
if (gnc_hbci_get_account_countrycode(gnc_acc))
gnc_hbci_set_account_countrycode (gnc_acc, 0);
if (gnc_hbci_get_account_uid(gnc_acc))
gnc_hbci_set_account_uid (gnc_acc, 0);
return NULL;
}
@@ -112,109 +92,18 @@ accounts_save_kvp (GHashTable *hash)
static void
update_accounts_forbank (GtkWidget *parent, HBCI_API *api,
const HBCI_Bank *bank,
GNCInteractor *inter);
static void
update_accounts_foruser (GtkWidget *parent, HBCI_API *api,
const HBCI_User *user,
GNCInteractor *inter);
static gboolean
update_accounts_forcustomer (GtkWidget *parent, HBCI_API *api,
const HBCI_Customer *cust,
GNCInteractor *inter);
void
update_accounts (GtkWidget *parent, HBCI_API *api, GNCInteractor *inter)
update_accounts (GtkWidget *parent, AB_BANKING *api, GNCInteractor *inter)
{
const list_HBCI_Bank *banklist;
list_HBCI_Bank_iter *begin;
g_assert(api);
banklist = HBCI_API_bankList (api);
/*printf("%d banks found.\n", list_HBCI_Bank_size (banklist)); */
if (list_HBCI_Bank_size (banklist) == 0) {
/* Zero banks? nothing to do. */
return;
}
else if (list_HBCI_Bank_size (banklist) == 1) {
begin = list_HBCI_Bank_begin (banklist);
update_accounts_forbank (parent, api,
list_HBCI_Bank_iter_get (begin), inter);
list_HBCI_Bank_iter_delete (begin);
}
else {
printf("Sorry, multiple banks not yet supported.\n");
}
}
static void
update_accounts_forbank (GtkWidget *parent, HBCI_API *api,
const HBCI_Bank *bank,
GNCInteractor *inter)
{
const list_HBCI_User *userlist;
const HBCI_User *user;
g_assert(bank);
userlist = HBCI_Bank_users (bank);
if (list_HBCI_User_size (userlist) == 0) {
printf("update_accounts_forbank: Oops, zero users found.\n");
/* Zero users? nothing to do. */
return;
}
user = choose_one_user (GNCInteractor_parent(inter), userlist);
update_accounts_foruser (parent, api, user, inter);
}
static void
update_accounts_foruser (GtkWidget *parent, HBCI_API *api,
const HBCI_User *user,
GNCInteractor *inter)
{
const list_HBCI_Customer *customerlist;
const HBCI_Customer *customer;
g_assert(user);
customerlist = HBCI_User_customers (user);
if (list_HBCI_Customer_size (customerlist) == 0) {
printf("update_accounts_foruser: Oops, zero customers found.\n");
/* Zero customers? nothing to do. */
return;
}
customer = choose_one_customer (GNCInteractor_parent(inter), customerlist);
update_accounts_forcustomer (parent, api, customer, inter);
}
static gboolean
update_accounts_forcustomer (GtkWidget *parent, HBCI_API *api,
const HBCI_Customer *cust, GNCInteractor *inter)
{
HBCI_OutboxJob *job;
HBCI_Outbox *outbox;
gboolean result;
g_assert(cust);
/* this const-warning is okay and can be ignored. */
job = HBCI_OutboxJob_new("JobGetAccounts", (HBCI_Customer *)cust, "");
outbox = HBCI_Outbox_new();
HBCI_Outbox_addJob(outbox, job);
/* Execute Outbox. */
result = gnc_hbci_api_execute (parent, api, outbox, job, inter);
HBCI_Outbox_delete (outbox);
return result;
}
struct hbci_acc_cb_data
{
HBCI_API *api;
AB_BANKING *api;
GHashTable *hash;
};
@@ -222,9 +111,9 @@ static gpointer
gnc_hbci_new_hash_from_kvp_cb (Account *gnc_acc, gpointer user_data)
{
struct hbci_acc_cb_data *data = user_data;
gnc_HBCI_Account *hbci_acc = NULL;
AB_ACCOUNT *hbci_acc = NULL;
hbci_acc = (gnc_HBCI_Account *) gnc_hbci_get_hbci_acc (data->api, gnc_acc);
hbci_acc = (AB_ACCOUNT *) gnc_hbci_get_hbci_acc (data->api, gnc_acc);
if (hbci_acc) {
g_hash_table_insert (data->hash, hbci_acc, gnc_acc);
}
@@ -232,7 +121,7 @@ gnc_hbci_new_hash_from_kvp_cb (Account *gnc_acc, gpointer user_data)
}
GHashTable *
gnc_hbci_new_hash_from_kvp (HBCI_API *api)
gnc_hbci_new_hash_from_kvp (AB_BANKING *api)
{
GHashTable *hash;
@@ -286,301 +175,3 @@ gnc_test_dir_exist_error (GtkWindow *parent, const char *filename)
}
GList *
gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
GList *accountlist)
{
GWEN_DB_NODE *response, *n;
g_assert(api);
g_assert(outbox);
/*g_assert(accountlist);*/
response = HBCI_Outbox_response(outbox);
/*printf("gnc_processOutboxResponse: Complete response:\n");
GWEN_DB_Dump(response, stdout, 1);*/
n=GWEN_DB_GetFirstGroup(response);
while (n){
if (strcasecmp(GWEN_DB_GroupName(n), "AccountData")==0) {
/* found account data, create account */
const char *accountId;
const char *accountSubId;
const char *bankCode;
int country;
const char *custid;
const char *currency;
const char *acc_name;
const char *acc_name1;
/*list_HBCI_Customer *customers;*/
/*HBCI_User *user;*/
HBCI_Bank *bank;
country=GWEN_DB_GetIntValue(n, "country", 0, 280);
custid=GWEN_DB_GetCharValue(n, "customer", 0, "");
bankCode=GWEN_DB_GetCharValue(n, "bankcode", 0, "");
accountId=GWEN_DB_GetCharValue(n, "accountid", 0, "");
accountSubId=GWEN_DB_GetCharValue(n, "accountsubid", 0, "");
if (strlen(bankCode)==0 || strlen(accountId)==0 || strlen(custid)==0) {
printf("gnc_processOutboxResponse: AccountData without bank code/account id/customer id\n");
continue;
}
currency = GWEN_DB_GetCharValue(n, "currency", 0, NULL);
acc_name = GWEN_DB_GetCharValue(n, "name", 0, NULL);
acc_name1 = GWEN_DB_GetCharValue(n, "name1", 0, NULL);
bank = HBCI_API_findBank(api, country, bankCode);
if (bank) {
/* bank uses a different bank code for the accounts, so find
* the matching bank for the given customer */
/*customers=getCustomers(country, "*", custid);
if (customers.empty()) {
DBG_ERROR(0, "Unknown customer %d/%s/%s",
country, bankCode.c_str(), custid.c_str());
GWEN_DB_Group_free(db);
return Error("AqMoneyAPI::processOutboxResponse",
ERROR_LEVEL_NORMAL,
HBCI_ERROR_CODE_UNKNOWN,
ERROR_ADVISE_DONTKNOW,
"Unknown customer");
}
if (customers.size()!=1) {
DBG_ERROR(0, "Ambiguous customer %d/%s/%s",
country, bankCode.c_str(), custid.c_str());
GWEN_DB_Group_free(db);
return Error("AqMoneyAPI::processOutboxResponse",
ERROR_LEVEL_NORMAL,
HBCI_ERROR_CODE_UNKNOWN,
ERROR_ADVISE_DONTKNOW,
"Ambiguous customer");
}
user=customers.front().ref().user();
bank=user.ref().bank();*/
}
{
/* Check if such an account already exists */
gnc_HBCI_Account *acc =
list_HBCI_Account_find(accountlist, bank, bankCode, accountId);
if (acc) {
/* Update account information */
printf("gnc_processOutboxResponse: Account %d/%s/%s already exists, updating.\n",
country, bankCode, accountId);
}
else {
/* Create new account object */
acc = gnc_HBCI_Account_new(bank, bankCode, accountId);
/* Add it to our internal list. */
accountlist = g_list_append(accountlist, acc);
printf("gnc_processOutboxResponse: Added account %d/%s/%s\n",
country, bankCode, accountId);
}
gnc_HBCI_Account_set_currency(acc, currency);
gnc_HBCI_Account_set_name(acc, acc_name);
gnc_HBCI_Account_set_name1(acc, acc_name1);
gnc_HBCI_Account_set_customer(acc, custid);
}
} /* if "AccountData" */
else if (strcasecmp(GWEN_DB_GroupName(n), "bankmsg")==0) {
/* add to existing bank messages */
/*GWEN_DB_AddGroup(_bankMessages, GWEN_DB_Group_dup(n));
fprintf(stderr, "------------------------------------\n");
fprintf(stderr,
"Message from \"%s\":\n",
GWEN_DB_GetCharValue(n, "bankCode", 0, "<unknown>"));
fprintf(stderr, "Subject: %s\n",
GWEN_DB_GetCharValue(n, "subject", 0, "<empty>"));
fprintf(stderr, "\n%s\n\n",
GWEN_DB_GetCharValue(n, "text", 0, "<empty>"));*/
}
n=GWEN_DB_GetNextGroup(n);
} /* while n */
GWEN_DB_Group_free(response);
//printf("gnc_processOutboxResponse: accountlist.size: %d\n", g_list_length(accountlist));
return accountlist;
}
gboolean
gnc_hbci_evaluate_GetKeys(HBCI_Outbox *outbox, HBCI_OutboxJob *job,
HBCI_Customer *newcustomer)
{
GWEN_DB_NODE *rsp;
GWEN_DB_NODE *n;
/*HBCI_Error *err;*/
HBCI_RSAKey *_cryptKey = NULL;
HBCI_RSAKey *_signKey = NULL;
g_assert(outbox);
g_assert(newcustomer);
rsp = HBCI_Job_responseData(HBCI_OutboxJob_Job(job));
if (!rsp) {
fprintf(stderr, "JobGetKeys::evaluate: no response data\n");
return FALSE;
}
/*printf("JobGetKeys: Complete response:\n");
GWEN_DB_Dump(rsp, stderr, 1);*/
n=GWEN_DB_GetFirstGroup(rsp);
while(n) {
if (strcasecmp(GWEN_DB_GroupName(n), "GetKeyResponse")==0) {
unsigned int bs;
const void *p;
GWEN_DB_NODE *keydb;
const char defaultExpo[3]={0x01, 0x00, 0x01};
gboolean iscrypt;
//DBG_NOTICE(0, "Found Key response");
iscrypt=FALSE;
keydb=GWEN_DB_Group_new("key");
GWEN_DB_SetCharValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"type",
"RSA");
// TODO: check for the correct exponent (for now assume 65537)
GWEN_DB_SetBinValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"data/e",
defaultExpo,
sizeof(defaultExpo));
GWEN_DB_SetIntValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"data/public",
1);
iscrypt=(strcasecmp(GWEN_DB_GetCharValue(n,
"keyname/keytype", 0,
"V"), "V")==0);
GWEN_DB_SetCharValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"name",
GWEN_DB_GetCharValue(n,
"keyname/keytype", 0,
"V"));
GWEN_DB_SetCharValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"owner",
GWEN_DB_GetCharValue(n, "keyname/userId", 0, ""));
GWEN_DB_SetIntValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"number",
GWEN_DB_GetIntValue(n, "keyname/keynum", 0, 0));
GWEN_DB_SetIntValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"version",
GWEN_DB_GetIntValue(n, "keyname/keyversion", 0, 0));
p=GWEN_DB_GetBinValue(n, "key/modulus", 0, 0, 0 , &bs);
if (!p || !bs) {
fprintf(stderr, "JobGetKeys::evaluate: no modulus\n");
return FALSE;
}
GWEN_DB_SetBinValue(keydb,
GWEN_DB_FLAGS_OVERWRITE_VARS,
"data/n",
p, bs);
if (iscrypt)
_cryptKey = HBCI_RSAKey_new(iscrypt, keydb);
else
_signKey = HBCI_RSAKey_new(iscrypt, keydb);
fprintf(stderr, "gnc_hbci_evaluate_GetKeys: Created %s key\n", iscrypt?"crypt":"sign");
} // if we have a key response
n=GWEN_DB_GetNextGroup(n);
} // while
// Key creation finished. Now add them to the medium @<40>%$!!!
if (!_cryptKey) {
printf("gnc_hbci_evaluate_GetKeys: Oops, no cryptKey received.\n");
return FALSE;
}
{
HBCI_MediumRDHBase *mrdh;
HBCI_Medium *medium;
const HBCI_Bank *bank;
const HBCI_User *user;
HBCI_Error *err;
// get some vars
user = HBCI_Customer_user(newcustomer);
bank = HBCI_User_bank(user);
medium = (HBCI_Medium *) HBCI_User_medium(user);
mrdh = HBCI_Medium_MediumRDHBase (medium);
// mount medium
err = HBCI_Medium_mountMedium(medium, "");
if (err && !HBCI_Error_isOk(err)) {
fprintf(stderr, "JobGetKeys::commit: 1\n");
return FALSE;
}
// select context
err = HBCI_Medium_selectContext(medium, HBCI_Bank_country(bank),
HBCI_Bank_bankCode(bank),
HBCI_User_userId(user));
if (err && !HBCI_Error_isOk(err)) {
HBCI_Medium_unmountMedium(medium, "");
fprintf(stderr, "JobGetKeys::commit: 2\n");
return FALSE;
}
// set crypt key
if (_cryptKey) {
fprintf(stderr, "Setting Institute Crypt Key\n");
if (!HBCI_RSAKey_isCryptoKey(_cryptKey)) {
fprintf(stderr, "Crypt key expected\n");
return FALSE;
}
err = HBCI_MediumRDHBase_setInstituteCryptKey(mrdh, _cryptKey);
if (err && !HBCI_Error_isOk(err)) {
HBCI_Medium_unmountMedium(medium, "");
fprintf(stderr, "JobGetKeys::commit: 3\n");
return FALSE;
}
}
// set sign key
if (_signKey) {
fprintf(stderr, "Setting Institute Sign Key\n");
err=HBCI_MediumRDHBase_setInstituteSignKey(mrdh, _signKey);
if (err && !HBCI_Error_isOk(err)) {
HBCI_Medium_unmountMedium(medium, "");
fprintf(stderr, "JobGetKeys::commit: 4\n");
return FALSE;
}
if (!HBCI_MediumRDHBase_hasInstSignKey(mrdh)) {
fprintf(stderr, "What ??? I just set the signkey but there is none ?!\n");
}
}
err = HBCI_Medium_unmountMedium(medium, "");
if (err && !HBCI_Error_isOk(err)) {
fprintf(stderr, "JobGetKeys::commit: 5\n");
return FALSE;
}
fprintf(stderr, "New institute keys activated\n");
}
// use result returned from lower class
return TRUE;
}

View File

@@ -24,7 +24,7 @@
#define DRUID_HBCI_UTILS_H
#include <gnome.h>
#include <openhbci2/api.h>
#include <aqbanking/banking.h>
#include "hbci-interaction.h"
#include "gnc-hbci-utils.h"
@@ -36,17 +36,17 @@ void accounts_save_kvp (GHashTable *hash);
/** Update the account list in all the banks stored in this
* HBCI_API. Straightforward, if we have only one bank and one user
* AB_BANKING. Straightforward, if we have only one bank and one user
* with one customer. All other cases are not currently
* implemented. */
void update_accounts (GtkWidget *parent, HBCI_API *api,
void update_accounts (GtkWidget *parent, AB_BANKING *api,
GNCInteractor *inter);
/** Builds a new hash table mapping all HBCI accounts to Gnucash
* accounts, where the Gnucash accounts already have the reference
* strings stored in their kvp's. */
GHashTable *
gnc_hbci_new_hash_from_kvp (HBCI_API *api);
gnc_hbci_new_hash_from_kvp (AB_BANKING *api);
gboolean
gnc_verify_exist_or_new_file (GtkWidget *parent, const char *filename);
@@ -54,13 +54,5 @@ gnc_verify_exist_or_new_file (GtkWidget *parent, const char *filename);
gboolean
gnc_test_dir_exist_error (GtkWindow *parent, const char *filename);
GList *
gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
GList *accountlist);
/* Get keys from Job; store them in the customer's medium @<40>%&! */
gboolean
gnc_hbci_evaluate_GetKeys(HBCI_Outbox *outbox, HBCI_OutboxJob *job,
HBCI_Customer *newcustomer);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,344 +0,0 @@
/********************************************************************\
* gnc-hbci-account.c -- hbci account functions *
* Copyright (C) 2004 Christian Stimming *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
#include "config.h"
#include "gnc-hbci-account.h"
#include <gnome.h>
#include <errno.h>
#include <openhbci2.h>
#include <openhbci2/error.h>
#include "Account.h"
#include "hbci-interaction.h"
/* static short module = MOD_IMPORT; */
struct _gnc_HBCI_Account
{
const HBCI_Bank *bank;
char *bankCode;
char *accountid;
char *name;
char *customer;
char *currency;
char *name1;
};
gnc_HBCI_Account *gnc_HBCI_Account_new(const HBCI_Bank *bank,
const char *bankCode,
const char *accountid)
{
gnc_HBCI_Account *r = g_new0(gnc_HBCI_Account, 1);
r->bank = bank;
r->bankCode = g_strdup (bankCode);
r->accountid = g_strdup (accountid);
return r;
}
void gnc_HBCI_Account_delete (gnc_HBCI_Account *h)
{
if (!h) return;
g_free(h->bankCode);
g_free(h->accountid);
if (h->name) g_free(h->name);
if (h->customer) g_free(h->customer);
if (h->currency) g_free(h->currency);
if (h->name1) g_free(h->name1);
g_free(h);
}
const char *gnc_HBCI_Account_accountId (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->accountid;
}
const char *gnc_HBCI_Account_bankCode (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->bankCode;
}
const HBCI_Bank *
gnc_HBCI_Account_bank (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->bank;
}
void gnc_HBCI_Account_set_name (gnc_HBCI_Account *hbci_acc, const char *n)
{
g_assert(hbci_acc);
if (hbci_acc->name) g_free(hbci_acc->name);
hbci_acc->name = g_strdup(n);
}
void gnc_HBCI_Account_set_customer (gnc_HBCI_Account *hbci_acc, const char *n)
{
g_assert(hbci_acc);
if (hbci_acc->customer) g_free(hbci_acc->customer);
hbci_acc->customer = g_strdup(n);
}
void gnc_HBCI_Account_set_currency (gnc_HBCI_Account *hbci_acc, const char *n)
{
g_assert(hbci_acc);
if (hbci_acc->currency) g_free(hbci_acc->currency);
hbci_acc->currency = g_strdup(n);
}
void gnc_HBCI_Account_set_name1 (gnc_HBCI_Account *hbci_acc, const char *n)
{
g_assert(hbci_acc);
if (hbci_acc->name1) g_free(hbci_acc->name1);
hbci_acc->name1 = g_strdup(n);
}
const char *gnc_HBCI_Account_name (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->name;
}
const char *gnc_HBCI_Account_customer (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->customer;
}
const char *gnc_HBCI_Account_currency (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->currency;
}
const char *gnc_HBCI_Account_name1 (const gnc_HBCI_Account *hbci_acc)
{
g_assert(hbci_acc);
return hbci_acc->name1;
}
gchar *gnc_HBCI_Account_longname(const gnc_HBCI_Account *hacc)
{
g_assert(hacc);
/* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
return g_strdup_printf(_("%s at %s (code %s)"),
gnc_HBCI_Account_accountId (hacc),
gnc_HBCI_Account_bank (hacc) ?
HBCI_Bank_name (gnc_HBCI_Account_bank (hacc)) :
gnc_HBCI_Account_bankCode (hacc),
gnc_HBCI_Account_bankCode (hacc));
}
void *list_HBCI_Account_foreach(GList *h_list,
void*(*func_cb)(gnc_HBCI_Account *acc,
void *user_data),
void *user_data)
{
GList *iter;
g_assert(func_cb);
void *res = NULL;
if (!h_list) return NULL;
for (iter = h_list; iter; iter = iter->next)
{
if (iter->data)
res = func_cb(iter->data, user_data);
if (res)
break;
}
return res;
}
static void* del_func(gnc_HBCI_Account *acc, void *user_data)
{
gnc_HBCI_Account_delete(acc);
return NULL;
}
void list_HBCI_Account_delete(GList *list_HBCI_Account)
{
list_HBCI_Account_foreach(list_HBCI_Account, del_func, NULL);
g_list_free (list_HBCI_Account);
}
static void *hbci_find_acc_cb(gnc_HBCI_Account *acc, void *user_data)
{
gnc_HBCI_Account *new_acc = user_data;
if (gnc_HBCI_Account_bank(acc) == gnc_HBCI_Account_bank(new_acc)) {
if (strcmp(gnc_HBCI_Account_accountId(acc),
gnc_HBCI_Account_accountId(new_acc))==0) {
return acc;
}
}
return NULL;
}
gnc_HBCI_Account *list_HBCI_Account_find(GList *list,
const HBCI_Bank *bank,
const char *bankCode,
const char *accountid)
{
gnc_HBCI_Account *acc;
gnc_HBCI_Account *res;
if (list == NULL) return NULL;
g_assert(bank);
g_assert(bankCode);
g_assert(accountid);
/* Create the wrapper object */
acc = gnc_HBCI_Account_new(bank, bankCode, accountid);
/* Check if such an account already exists */
res = list_HBCI_Account_foreach(list, hbci_find_acc_cb, acc);
gnc_HBCI_Account_delete(acc);
return res;
}
/* ------------------------------------------------------------ */
#define HBCI_ACCOUNT_ID "account-id"
#define HBCI_BANK_CODE "bank-code"
#define HBCI_COUNTRY_CODE "country-code"
#define HBCI_ACCOUNT_CURRENCY "acc-currency"
#define HBCI_ACCOUNT_NAME "acc-name"
#define HBCI_ACCOUNT_NAME1 "acc-name1"
#define HBCI_ACCOUNT_CUSTOMER "acc-customer"
/** Constructor from a kvp_frame */
gnc_HBCI_Account *gnc_HBCI_Account_from_kvp(kvp_frame *k, HBCI_API *api)
{
gnc_HBCI_Account *res = NULL;
HBCI_Bank *bank;
char *bankcode;
int countrycode;
g_assert(k);
bankcode = kvp_value_get_string (kvp_frame_get_slot(k, HBCI_BANK_CODE));
countrycode = kvp_value_get_gint64 (kvp_frame_get_slot(k, HBCI_COUNTRY_CODE));
if (bankcode && (strlen(bankcode)>0) && (countrycode > 0)) {
bank = HBCI_API_findBank (api, countrycode, bankcode);
/*printf("gnc_HBCI_Account_from_kvp: kvpframe has blz %s and ccode %d and accountid %s, bank %p\n",
bankcode, countrycode, kvp_value_get_string
(kvp_frame_get_slot(k, HBCI_ACCOUNT_ID)), bank);*/
if (!bank) {
printf("gnc_HBCI_Account_from_kvp: oops, the file has a HBCI_Account but its bank could not be found in the HBCI_API. Ignoring this account.\n");
return NULL;
}
res = gnc_HBCI_Account_new(bank,
bankcode,
kvp_value_get_string
(kvp_frame_get_slot(k, HBCI_ACCOUNT_ID)));
gnc_HBCI_Account_set_currency(res, kvp_value_get_string
(kvp_frame_get_slot(k, HBCI_ACCOUNT_CURRENCY)));
gnc_HBCI_Account_set_name(res, kvp_value_get_string
(kvp_frame_get_slot(k, HBCI_ACCOUNT_NAME)));
gnc_HBCI_Account_set_name1(res, kvp_value_get_string
(kvp_frame_get_slot(k, HBCI_ACCOUNT_NAME1)));
gnc_HBCI_Account_set_customer(res, kvp_value_get_string
(kvp_frame_get_slot(k, HBCI_ACCOUNT_CUSTOMER)));
}
return res;
}
/** Creates a kvp_frame from this TransTempl */
kvp_frame *gnc_HBCI_Account_to_kvp(const gnc_HBCI_Account *t)
{
kvp_frame *k = kvp_frame_new();
g_assert(t);
kvp_frame_set_slot(k, HBCI_ACCOUNT_ID,
kvp_value_new_string(gnc_HBCI_Account_accountId(t)));
kvp_frame_set_slot(k, HBCI_BANK_CODE,
kvp_value_new_string(gnc_HBCI_Account_bankCode (t)));
kvp_frame_set_slot(k, HBCI_ACCOUNT_CURRENCY,
kvp_value_new_string(gnc_HBCI_Account_currency (t)));
kvp_frame_set_slot(k, HBCI_ACCOUNT_NAME,
kvp_value_new_string(gnc_HBCI_Account_name (t)));
kvp_frame_set_slot(k, HBCI_ACCOUNT_NAME1,
kvp_value_new_string(gnc_HBCI_Account_name1 (t)));
kvp_frame_set_slot(k, HBCI_ACCOUNT_CUSTOMER,
kvp_value_new_string(gnc_HBCI_Account_customer (t)));
if (gnc_HBCI_Account_bank(t))
kvp_frame_set_slot(k, HBCI_COUNTRY_CODE,
kvp_value_new_gint64(HBCI_Bank_country
(gnc_HBCI_Account_bank(t))));
return k;
}
struct _glistapi
{
GList *res;
HBCI_API *api;
};
/** Creates a GList of gnc_HBCI_Account from a GList of kvp_values which
in turn contain a kvp_frame. */
static void glist_from_kvp_func(gpointer data, gpointer user_data)
{
struct _glistapi *mydata = user_data;
kvp_value *k = data;
gnc_HBCI_Account *new_acc = gnc_HBCI_Account_from_kvp(kvp_value_get_frame(k),
mydata->api);
if (new_acc)
mydata->res = g_list_append(mydata->res, new_acc);
}
/** Creates a GList of gnc_HBCI_Account from a GList of kvp_values which
in turn contain a kvp_frame. */
GList *gnc_HBCI_Account_glist_from_kvp_glist(GList *v, HBCI_API *api)
{
struct _glistapi mydata;
if (!v) return NULL;
mydata.res = NULL;
mydata.api = api;
g_list_foreach (v, glist_from_kvp_func, &mydata);
return mydata.res;
}
/** Creates a GList of kvp_value (which in turn contain a kvp_frame)
from a GList of gnc_HBCI_Account. */
static void glist_to_kvp_func(gpointer data, gpointer user_data)
{
GList **tmp = user_data;
GList *res = *tmp;
gnc_HBCI_Account *g = data;
*tmp = g_list_append(res,
kvp_value_new_frame_nc(gnc_HBCI_Account_to_kvp(g)));
}
/** Creates a GList of kvp_value (which in turn contain a kvp_frame)
from a GList of gnc_HBCI_Account. */
GList *gnc_HBCI_Account_kvp_glist_from_glist(GList *k)
{
GList *res = NULL;
if (!k) return NULL;
g_list_foreach (k, glist_to_kvp_func, &res);
return res;
}

View File

@@ -1,106 +0,0 @@
/********************************************************************\
* gnc-hbci-account.h -- hbci account definition *
* Copyright (C) 2004 Christian Stimming *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
/** @file
Hbci account definition
*/
#ifndef GNC_HBCI_ACCOUNT_H
#define GNC_HBCI_ACCOUNT_H
#include <glib.h>
#include <gnome.h>
#include <openhbci2/api.h>
#include "gnc-book.h"
typedef struct _gnc_HBCI_Account gnc_HBCI_Account;
/** @name HBCI_Account wrapper class */
/*@{*/
/** Constructor */
gnc_HBCI_Account *gnc_HBCI_Account_new(const HBCI_Bank *bank,
const char *bankCode,
const char *accountid);
/** Returns the account id */
const char *gnc_HBCI_Account_accountId (const gnc_HBCI_Account *hbci_acc);
/** Returns the bank code -- this might be different than the actual
* bank's bank code */
const char *gnc_HBCI_Account_bankCode (const gnc_HBCI_Account *hbci_acc);
void gnc_HBCI_Account_set_name (gnc_HBCI_Account *hbci_acc, const char *n);
void gnc_HBCI_Account_set_customer (gnc_HBCI_Account *hbci_acc, const char *n);
void gnc_HBCI_Account_set_currency (gnc_HBCI_Account *hbci_acc, const char *n);
void gnc_HBCI_Account_set_name1 (gnc_HBCI_Account *hbci_acc, const char *n);
const char *gnc_HBCI_Account_name (const gnc_HBCI_Account *hbci_acc);
const char *gnc_HBCI_Account_customer (const gnc_HBCI_Account *hbci_acc);
const char *gnc_HBCI_Account_currency (const gnc_HBCI_Account *hbci_acc);
const char *gnc_HBCI_Account_name1 (const gnc_HBCI_Account *hbci_acc);
/** Returns the bank this account belongs to */
const HBCI_Bank *
gnc_HBCI_Account_bank (const gnc_HBCI_Account *hbci_acc);
/** Destructor for this account object */
void gnc_HBCI_Account_delete (gnc_HBCI_Account *hbci_acc);
/** Returns a newly allocated string that is a human-readable
* description of this account. The returned string will be owned by
* the caller. */
gchar *gnc_HBCI_Account_longname(const gnc_HBCI_Account *hbci_acc);
/*@}*/
/** @name List of hbci accounts */
/*@{*/
/** Foreach function */
void *list_HBCI_Account_foreach(GList *list_HBCI_Account,
void*(*func_cb)(gnc_HBCI_Account *acc,
void *user_data),
void *user_data);
/** Delete each element of a GList of HBCI_Accounts and finally the
* list itself. */
void list_HBCI_Account_delete(GList *list_HBCI_Account);
/** Searches for an account with the given data fields. Returns this
* account, or NULL if none was found. */
gnc_HBCI_Account *list_HBCI_Account_find(GList *list_HBCI_Account,
const HBCI_Bank *bank,
const char *bankCode,
const char *accountid);
/*@}*/
/** @name Serialization -- List of gnc_HBCI_Accounts to kvp_frame and
* back */
/*@{*/
/** Constructor from a kvp_frame (the kvp_frame is left unchanged) */
gnc_HBCI_Account *gnc_HBCI_Account_from_kvp(kvp_frame *k, HBCI_API *api);
/** Creates a kvp_frame from this TransTempl */
kvp_frame *gnc_HBCI_Account_to_kvp(const gnc_HBCI_Account *t);
/** Creates a GList of gnc_HBCI_Account from a GList of kvp_values which
in turn contain a kvp_frame. */
GList *gnc_HBCI_Account_glist_from_kvp_glist(GList *v, HBCI_API *api);
/** Creates a GList of kvp_value (which in turn contain a kvp_frame)
from a GList of gnc_HBCI_Account. */
GList *gnc_HBCI_Account_kvp_glist_from_glist(GList *k);
/*@}*/
#endif /* GNC_HBCI_ACCOUNT_H */

View File

@@ -23,7 +23,7 @@
#include "config.h"
#include "gnc-hbci-getbalance.h"
#include <openhbci2/api.h>
#include <aqbanking/banking.h>
#include "gnc-ui.h"
#include "gnc-numeric.h"
@@ -32,45 +32,44 @@
#include "hbci-interaction.h"
#include "gnc-hbci-utils.h"
#include "dialog-hbcitrans.h"
/* #include "dialog-hbcitrans.h" */
void gnc_hbci_getbalance_debugprint(HBCI_OutboxJob *balance_job,
const gnc_HBCI_Account *h_acc);
void gnc_hbci_getbalance_debugprint(AB_JOB *balance_job,
const AB_ACCOUNT *h_acc);
#if 0
static void
bal_print_debug(const char *name,
const HBCI_Value *val,
const AB_VALUE *val,
gboolean negative,
const char *date_str,
const char *time_str)
{
char *str = HBCI_Value_toReadableString (val);
char *str = gnc_AB_VALUE_toReadableString (val);
printf("GetBalance: %s%s %s at date %s %s",
(negative ? "-" : ""), str,
name, date_str, time_str);
free (str);
}
#endif
void
gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
{
HBCI_API *api = NULL;
HBCI_Outbox *outbox = NULL;
const gnc_HBCI_Account *h_acc = NULL;
AB_BANKING *api = NULL;
const AB_ACCOUNT *h_acc = NULL;
GNCInteractor *interactor = NULL;
const HBCI_Customer *customer = NULL;
GList *hbci_accountlist = NULL;
g_assert(parent);
if (gnc_acc == NULL)
return;
/* Get API */
api = gnc_hbci_api_new_currentbook (parent, &interactor, &hbci_accountlist);
api = gnc_AB_BANKING_new_currentbook (parent, &interactor);
if (api == NULL) {
printf("gnc_hbci_getbalance: Couldn't get HBCI API.\n");
printf("gnc_hbci_getbalance: Couldn't get AB_BANKING API.\n");
return;
}
g_assert (interactor);
@@ -79,35 +78,32 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
h_acc = gnc_hbci_get_hbci_acc (api, gnc_acc);
if (h_acc == NULL) {
printf("gnc_hbci_getbalance: No HBCI account found.\n");
/* FIXME: free unneeded data */
return;
}
/* printf("gnc_hbci_getbalance: HBCI account no. %s found.\n",
gnc_HBCI_Account_accountId (h_acc)); */
AB_ACCOUNT_accountId (h_acc)); */
/* Get the customer that should be doing this job. */
customer = gnc_hbci_get_first_customer(h_acc);
if (!customer)
return;
/* printf("gnc_hbci_getbalance: Customer id %s found.\n",
HBCI_Customer_custId ((HBCI_Customer *)customer)); */
{
/* Execute a GetBalance job. */
HBCI_OutboxJob *job;
AB_JOB *job;
job = HBCI_OutboxJob_new("JobGetBalance", (HBCI_Customer *)customer,
gnc_HBCI_Account_accountId(h_acc));
HBCI_Job_setProperty(HBCI_OutboxJob_Job(job), "allAccounts", "N");
job = AB_JobGetBalance_new((AB_ACCOUNT*)h_acc);
if (!AB_Job_CheckAvailability(job)) {
printf("gnc_hbci_getbalance: JobGetBalance not avaiable for this account.\n");
/* FIXME: free unneeded data */
return;
}
/* Add job to API queue */
outbox = HBCI_Outbox_new();
HBCI_Outbox_addJob (outbox, job);
AB_Banking_EnqueueJob(api, job);
/* Execute Outbox. */
if (!gnc_hbci_api_execute (parent, api, outbox, job, interactor)) {
if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
/* HBCI_API_executeOutbox failed. */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
/* AB_BANKING_executeOutbox failed. */
AB_Banking_DequeueJob(api, job);
/* FIXME: free unneeded data */
return;
}
@@ -119,24 +115,23 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
job);
/* Clean up after ourselves. */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
HBCI_Outbox_delete(outbox);
gnc_hbci_api_save (api);
AB_Banking_DequeueJob(api, job);
gnc_AB_BANKING_save (api);
GNCInteractor_hide (interactor);
}
}
void gnc_hbci_getbalance_debugprint(HBCI_OutboxJob *job,
const gnc_HBCI_Account *h_acc)
#if 0
void gnc_hbci_getbalance_debugprint(AB_JOB *job,
const AB_ACCOUNT *h_acc)
{
GWEN_DB_NODE *response, *acc_bal;
GWEN_DB_NODE *noted_grp, *booked_grp;
HBCI_Value *booked_val, *noted_val;
AB_VALUE *booked_val, *noted_val;
/* time_t balance_tt, noted_tt, booked_tt; */
response = HBCI_Job_responseData(HBCI_OutboxJob_Job(job));
response = HBCI_Job_responseData(AB_JOB_Job(job));
if (!response)
return;
acc_bal =GWEN_DB_GetGroup(response,
@@ -147,13 +142,13 @@ void gnc_hbci_getbalance_debugprint(HBCI_OutboxJob *job,
noted_grp = GWEN_DB_GetGroup(response, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "noted");
booked_grp = GWEN_DB_GetGroup(response, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "booked");
booked_val = HBCI_Value_new(GWEN_DB_GetCharValue(booked_grp, "value", 0, "0"),
booked_val = AB_VALUE_new(GWEN_DB_GetCharValue(booked_grp, "value", 0, "0"),
GWEN_DB_GetCharValue(booked_grp, "currency", 0, "EUR"));
noted_val = HBCI_Value_new(GWEN_DB_GetCharValue(noted_grp, "value", 0, "0"),
noted_val = AB_VALUE_new(GWEN_DB_GetCharValue(noted_grp, "value", 0, "0"),
GWEN_DB_GetCharValue(noted_grp, "currency", 0, "EUR"));
printf("GetBalance: Balances for account %s :\n",
gnc_HBCI_Account_accountId (h_acc));
AB_ACCOUNT_accountId (h_acc));
bal_print_debug("Booked balance",
booked_val,
(strcasecmp(GWEN_DB_GetCharValue(booked_grp, "debitmark", 0, "C"),"D")==0),
@@ -165,24 +160,25 @@ void gnc_hbci_getbalance_debugprint(HBCI_OutboxJob *job,
GWEN_DB_GetCharValue(noted_grp, "date", 0, ""),
GWEN_DB_GetCharValue(noted_grp, "time", 0, ""));
/* bal_print_debug("Bank Line", */
/* gnc_HBCI_AccountBalance_bankLine (acc_bal), FALSE, */
/* AB_ACCOUNTBalance_bankLine (acc_bal), FALSE, */
/* balance_tt); */
/* bal_print_debug("Disposable amount", */
/* gnc_HBCI_AccountBalance_disposable (acc_bal), FALSE, */
/* AB_ACCOUNTBalance_disposable (acc_bal), FALSE, */
/* balance_tt); */
/* bal_print_debug("Already disposed", */
/* gnc_HBCI_AccountBalance_disposed (acc_bal), FALSE, */
/* AB_ACCOUNTBalance_disposed (acc_bal), FALSE, */
/* balance_tt); */
HBCI_Value_delete(booked_val);
HBCI_Value_delete(noted_val);
AB_VALUE_delete(booked_val);
AB_VALUE_delete(noted_val);
}
#endif
static gchar*
bal_print_balance(const char *format,
const HBCI_Value *val,
const AB_VALUE *val,
gboolean negative)
{
char *str = HBCI_Value_toReadableString (val);
char *str = gnc_AB_VALUE_toReadableString (val);
char *res = g_strdup_printf(format,
(negative ? "-" : ""),
str);
@@ -195,55 +191,40 @@ bal_print_balance(const char *format,
gboolean
gnc_hbci_getbalance_finish (GtkWidget *parent,
Account *gnc_acc,
const HBCI_OutboxJob *job)
const AB_JOB *job)
{
GWEN_DB_NODE *response, *acc_bal;
GWEN_DB_NODE *noted_grp, *booked_grp;
HBCI_Value *booked_val, *noted_val;
const AB_ACCOUNT_STATUS *response;
const AB_BALANCE *noted_grp, *booked_grp;
const AB_VALUE *booked_val, *noted_val;
time_t booked_tt;
gboolean booked_debit, noted_debit;
gboolean dialogres;
response = HBCI_Job_responseData((HBCI_Job*)HBCI_OutboxJob_Job_const(job));
response = AB_JobGetBalance_GetAccountStatus((AB_JOB*)job);
if (!response) {
printf("gnc_hbci_getbalance_finish: Oops, response == NULL.\n");
return TRUE;
}
acc_bal = GWEN_DB_GetGroup(response,
GWEN_PATH_FLAGS_NAMEMUSTEXIST, "balance");
if (!acc_bal) {
printf("gnc_hbci_getbalance_finish: Oops, acc_bal == NULL. Response was:\n");
GWEN_DB_Dump(response, stdout, 1);
return TRUE;
}
noted_grp = GWEN_DB_GetGroup(acc_bal, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "noted");
booked_grp = GWEN_DB_GetGroup(acc_bal, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "booked");
noted_grp = AB_AccountStatus_GetNotedBalance(response);
booked_grp = AB_AccountStatus_GetBookedBalance(response);
if (!booked_grp || !noted_grp) {
printf("gnc_hbci_getbalance_finish: Oops, booked_grp or noted_grp == NULL. Response was:\n");
GWEN_DB_Dump(response, stdout, 1);
printf("gnc_hbci_getbalance_finish: Oops, booked_grp or noted_grp == NULL.\n");
return TRUE;
}
booked_val = HBCI_Value_new(GWEN_DB_GetCharValue(booked_grp, "value", 0, "0"),
GWEN_DB_GetCharValue(booked_grp, "currency", 0, "EUR"));
booked_debit = (strcasecmp(GWEN_DB_GetCharValue(booked_grp, "debitmark", 0, "C"),"D")==0);
booked_val = AB_Balance_GetValue(booked_grp);
booked_debit = AB_Value_GetValue(booked_val) < 0;
noted_val = HBCI_Value_new(GWEN_DB_GetCharValue(noted_grp, "value", 0, "0"),
GWEN_DB_GetCharValue(noted_grp, "currency", 0, "EUR"));
noted_debit = (strcasecmp(GWEN_DB_GetCharValue(noted_grp, "debitmark", 0, "C"),"D")==0);
noted_val = AB_Balance_GetValue(noted_grp);
noted_debit = AB_Value_GetValue(noted_val) < 0;
{
HBCI_Date *a = HBCI_Date_new_string(GWEN_DB_GetCharValue(booked_grp, "date", 0, ""), 4);
booked_tt = GWEN_Time_toTime_t (AB_Balance_GetTime(booked_grp));
booked_tt = HBCI_Date_to_time_t (a);
HBCI_Date_delete(a);
}
if ((HBCI_Value_getValue (noted_val) == 0) &&
(HBCI_Value_getValue (booked_val) == 0))
if ((AB_Value_GetValue (noted_val) == 0) &&
(AB_Value_GetValue (booked_val) == 0))
{
gnome_ok_dialog_parented
/* Translators: Strings from this file are really only
@@ -261,7 +242,7 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
}
else
{
char *booked_str = HBCI_Value_toReadableString (booked_val);
char *booked_str = gnc_AB_VALUE_toReadableString (booked_val);
char *message1 = g_strdup_printf
(
/* Translators: The first %s is "-" if this amount is
@@ -272,7 +253,7 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
(booked_debit ? "-" : ""),
booked_str);
char *message2 =
((HBCI_Value_getValue (noted_val) == 0) ?
((AB_Value_GetValue (noted_val) == 0) ?
g_strdup_printf("%s", "") :
bal_print_balance
/* Translators: The first %s is "-" if this amount is
@@ -299,7 +280,7 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
if (dialogres)
{
gnc_numeric abs_value =
double_to_gnc_numeric (HBCI_Value_getValue (booked_val),
double_to_gnc_numeric (AB_Value_GetValue (booked_val),
xaccAccountGetCommoditySCU(gnc_acc),
GNC_RND_ROUND);
recnWindowWithBalance (parent,

View File

@@ -25,9 +25,9 @@
#include <gnome.h>
#include "Account.h"
#include <openhbci2/outboxjob.h>
#include <aqbanking/jobgetbalance.h>
/** Starts a GetBalance job, adds the job to the HBCI_API, and
/** Starts a GetBalance job, adds the job to the AB_BANKING, and
* (currently) calls executeOutbox. */
void
gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc);
@@ -37,7 +37,7 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc);
gboolean
gnc_hbci_getbalance_finish (GtkWidget *parent,
Account *gnc_acc,
const HBCI_OutboxJob *job);
const AB_JOB *job);
#endif /* GNC_HBCI_GETBALANCE_H */

View File

@@ -23,8 +23,6 @@
#include "config.h"
#include "gnc-hbci-gettrans.h"
#include <openhbci2/api.h>
#include "gnc-ui.h"
#include "gnc-numeric.h"
#include "gnc-date.h"
@@ -46,10 +44,9 @@
gboolean
gettrans_dates(GtkWidget *parent, Account *gnc_acc,
HBCI_Date **from_date, HBCI_Date **to_date);
GWEN_TIME **from_date, GWEN_TIME **to_date);
static void *trans_list_cb (GWEN_DB_NODE *trans_node, void *user_data);
static void *reports_cb(GWEN_DB_NODE *reportn, void *user_data);
static AB_TRANSACTION *trans_list_cb(AB_TRANSACTION *reportn, void *user_data);
struct trans_list_data
{
@@ -61,80 +58,53 @@ struct trans_list_data
void
gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
{
HBCI_API *api = NULL;
HBCI_Outbox *outbox = NULL;
const gnc_HBCI_Account *h_acc = NULL;
AB_BANKING *api = NULL;
const AB_ACCOUNT *h_acc = NULL;
GNCInteractor *interactor = NULL;
const HBCI_Customer *customer = NULL;
GList *hbci_accountlist = NULL;
g_assert(parent);
g_assert(gnc_acc);
/* Get the api */
api = gnc_hbci_api_new_currentbook (parent, &interactor, &hbci_accountlist);
api = gnc_AB_BANKING_new_currentbook (parent, &interactor);
if (api == NULL) {
printf("gnc_hbci_gettrans: Couldn't get HBCI API.\n");
return;
}
g_assert (interactor);
outbox = HBCI_Outbox_new();
/* Get the HBCI account */
/* Get HBCI account */
h_acc = gnc_hbci_get_hbci_acc (api, gnc_acc);
if (h_acc == NULL) {
printf("gnc_hbci_gettrans: No HBCI account found.\n");
printf("gnc_hbci_getbalance: No HBCI account found.\n");
/* FIXME: free unneeded data */
return;
}
/* printf("gnc_hbci_gettrans: HBCI account no. %s found.\n",
gnc_HBCI_Account_accountId (h_acc)); */
/* Get the customer that should be doing this job. */
customer = gnc_hbci_get_first_customer(h_acc);
if (!customer)
return;
/* g_assert (customer); */
/* printf("gnc_hbci_gettrans: Customer id %s found.\n",
HBCI_Customer_custId ((HBCI_Customer *)customer)); */
{
/* Execute a GetTransactions job. */
HBCI_OutboxJob *job;
AB_JOB *job;
Timespec until_timespec;
HBCI_Date *from_date, *to_date;
GWEN_TIME *from_date, *to_date;
/* Get the start and end dates for the Gettrans job. */
if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
return;
/* Use this as a local storage for the until_time below. */
timespecFromTime_t(&until_timespec, HBCI_Date_to_time_t(to_date));
timespecFromTime_t(&until_timespec, GWEN_Time_toTime_t(to_date));
/* Create OutboxJob */
job = HBCI_OutboxJob_new("JobGetTransactions", (HBCI_Customer *)customer,
gnc_HBCI_Account_accountId(h_acc));
{
HBCI_Job *jjob = HBCI_OutboxJob_Job(job);
char *tmp;
tmp = HBCI_Date_toString(from_date);
HBCI_Job_setProperty(jjob, "fromDate", tmp);
free(tmp);
tmp = HBCI_Date_toString(to_date);
HBCI_Job_setProperty(jjob, "toDate", tmp);
free(tmp);
}
HBCI_Date_delete (from_date);
HBCI_Date_delete (to_date);
job = AB_JobGetTransactions_new((AB_ACCOUNT*)h_acc);
AB_JobGetTransactions_SetFromTime(job, from_date);
AB_JobGetTransactions_SetToTime(job, to_date);
/* Add job to HBCI_API queue. */
HBCI_Outbox_addJob (outbox, job);
/* Add job to AB_BANKING queue. */
AB_Banking_EnqueueJob(api, job);
/* Execute Outbox. */
if (!gnc_hbci_api_execute (parent, api, outbox, job, interactor)) {
/* HBCI_API_executeOutbox failed. */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
/* AB_BANKING_executeOutbox failed. */
AB_Banking_DequeueJob(api, job);
return;
}
@@ -145,9 +115,8 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
gnc_hbci_gettrans_final(parent, gnc_acc, job, FALSE);
/* Clean up behind ourself. */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
HBCI_Outbox_delete(outbox);
gnc_hbci_api_save (api);
AB_Banking_DequeueJob(api, job);
gnc_AB_BANKING_save (api);
GNCInteractor_hide (interactor);
}
}
@@ -159,11 +128,10 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
deleted. */
gboolean
gettrans_dates(GtkWidget *parent, Account *gnc_acc,
HBCI_Date **from_date, HBCI_Date **to_date)
GWEN_TIME **from_date, GWEN_TIME **to_date)
{
Timespec last_timespec, until_timespec;
time_t now = time(NULL), time_convert;
struct tm tm;
time_t now = time(NULL);
gboolean use_last_date = TRUE,
use_earliest_date = TRUE, use_until_now = TRUE;
@@ -189,19 +157,17 @@ gettrans_dates(GtkWidget *parent, Account *gnc_acc,
/* Now calculate from date */
if (use_earliest_date)
*from_date = HBCI_Date_new_blank();
*from_date = GWEN_Time_fromSeconds(0);
else {
if (use_last_date)
last_timespec = gnc_hbci_get_account_trans_retrieval (gnc_acc);
time_convert = timespecToTime_t(last_timespec);
*from_date = HBCI_Date_new (localtime_r (&time_convert, &tm));
*from_date = GWEN_Time_fromSeconds(timespecToTime_t(last_timespec));
}
/* Now calculate to date */
if (use_until_now)
timespecFromTime_t (&until_timespec, now);
time_convert = timespecToTime_t (until_timespec);
*to_date = HBCI_Date_new (localtime_r (&time_convert, &tm));
*to_date = GWEN_Time_fromSeconds(timespecToTime_t (until_timespec));
return TRUE;
}
@@ -212,24 +178,15 @@ gettrans_dates(GtkWidget *parent, Account *gnc_acc,
gboolean
gnc_hbci_gettrans_final(GtkWidget *parent,
Account *gnc_acc,
const HBCI_OutboxJob *trans_job,
const AB_JOB *trans_job,
gboolean run_until_done)
{
/* Now add the retrieved transactions to the gnucash account. */
GWEN_DB_NODE *trans_list, *response;
AB_TRANSACTION_LIST2 *trans_list;
response = HBCI_Job_responseData((HBCI_Job*)HBCI_OutboxJob_Job_const(trans_job));
if (!response) {
printf("gnc_hbci_gettrans_final: Got no responseData.\n");
return FALSE;
}
trans_list = GWEN_DB_GetGroup(response, GWEN_PATH_FLAGS_NAMEMUSTEXIST,
"transactions");
trans_list = AB_JobGetTransactions_GetTransactions(trans_job);
if (!trans_list) {
printf("gnc_hbci_gettrans_final: No transactions section. Response was:\n");
GWEN_DB_Dump(response, stdout, 1);
gnome_ok_dialog_parented
(_("The HBCI import returned no transactions for the selected time period."),
@@ -237,15 +194,7 @@ gnc_hbci_gettrans_final(GtkWidget *parent,
return TRUE;
}
trans_list = GWEN_DB_GetGroup(trans_list,
GWEN_PATH_FLAGS_NAMEMUSTEXIST,
"booked");
if (!trans_list) {
printf("gnc_hbci_gettrans_final: No booked section. Response was:\n");
GWEN_DB_Dump(response, stdout, 1);
}
if (trans_list && (GWEN_DB_Groups_Count(trans_list) > 0)) {
if (trans_list && (AB_Transaction_List2_GetSize(trans_list) > 0)) {
struct trans_list_data data;
GNCImportMainMatcher *importer_generic_gui =
gnc_gen_trans_list_new(NULL, NULL, TRUE);
@@ -253,7 +202,7 @@ gnc_hbci_gettrans_final(GtkWidget *parent,
data.importer_generic = importer_generic_gui;
data.gnc_acc = gnc_acc;
GWEN_DB_Groups_Foreach (trans_list, reports_cb, &data);
AB_Transaction_List2_ForEach (trans_list, trans_list_cb, &data);
if (run_until_done)
return gnc_gen_trans_list_run (importer_generic_gui);
@@ -269,28 +218,10 @@ gnc_hbci_gettrans_final(GtkWidget *parent,
}
static void *reports_cb(GWEN_DB_NODE *reportn, void *user_data)
/* list_AB_TRANSACTION_foreach callback. The Conversion from HBCI to
GNC transaction is done here, once for each AB_TRANSACTION. */
static AB_TRANSACTION *trans_list_cb(AB_TRANSACTION *h_trans, void *user_data)
{
if (!reportn) {
/*DBG_INFO(0, "Oops: reportn is NULL");*/
return NULL;
}
if (strcasecmp(GWEN_DB_GroupName(reportn), "report")==0) {
return GWEN_DB_Groups_Foreach(reportn, trans_list_cb, user_data);
} // if report
else {
/*DBG_WARN(0, "Unknown section \"%s\"", GWEN_DB_GroupName(reportn));*/
}
return NULL;
}
/* list_HBCI_Transaction_foreach callback. The Conversion from HBCI to
GNC transaction is done here, once for each HBCI_Transaction. */
static void *trans_list_cb (GWEN_DB_NODE *trans_node,
void *user_data)
{
HBCI_Transaction *h_trans;
time_t current_time, tt1, tt2;
/*struct tm tm1, tm2;*/
Account *gnc_acc;
@@ -300,113 +231,82 @@ static void *trans_list_cb (GWEN_DB_NODE *trans_node,
struct trans_list_data *data = user_data;
g_assert(data);
if (!trans_node) return NULL;
if (!h_trans) return NULL;
gnc_acc = data->gnc_acc;
g_assert(gnc_acc);
book = xaccAccountGetBook(gnc_acc);
if (strcasecmp(GWEN_DB_GroupName(trans_node), "transaction")==0) {
/* Create wrapper HBCI_Transaction */
h_trans = HBCI_Transaction_new(trans_node);
/* Create new gnucash transaction for the given hbci one */
gnc_trans = xaccMallocTransaction(book);
xaccTransBeginEdit(gnc_trans);
gnc_trans = xaccMallocTransaction(book);
xaccTransBeginEdit(gnc_trans);
/*if(data.fi_id_valid==true){
gnc_import_set_trans_online_id(gnc_trans, data.fi_id);
}*/
/*if(data.fi_id_valid==true){
gnc_import_set_trans_online_id(gnc_trans, data.fi_id);
}*/
tt1 = HBCI_Date_to_time_t (HBCI_Transaction_date(h_trans));
tt2 = HBCI_Date_to_time_t (HBCI_Transaction_valutaDate(h_trans));
/*printf("Date? %s ValutaDate? %s", ctime(&tt1), ctime(&tt2));*/
/*tm1 = HBCI_Date_to_tm (HBCI_Transaction_date(h_trans));
tm2 = HBCI_Date_to_tm (HBCI_Transaction_valutaDate(h_trans));
printf("Date asc %s ValutaDate asc %s", asctime(&tm1), asctime(&tm2));*/
tt1 = GWEN_Time_toTime_t (AB_Transaction_GetDate(h_trans));
tt2 = GWEN_Time_toTime_t (AB_Transaction_GetValutaDate(h_trans));
/*printf("Date? %s ValutaDate? %s", ctime(&tt1), ctime(&tt2));*/
/*tm1 = GWEN_TIME_to_tm (AB_Transaction_date(h_trans));
tm2 = GWEN_TIME_to_tm (AB_Transaction_valutaDate(h_trans));
printf("Date asc %s ValutaDate asc %s", asctime(&tm1), asctime(&tm2));*/
/* Date / Time */
xaccTransSetDateSecs
(gnc_trans, HBCI_Date_to_time_t (HBCI_Transaction_valutaDate (h_trans)));
/* Date / Time */
xaccTransSetDateSecs
(gnc_trans, GWEN_Time_toTime_t (AB_Transaction_GetValutaDate (h_trans)));
current_time = time(NULL);
xaccTransSetDateEnteredSecs(gnc_trans, mktime(localtime(&current_time)));
current_time = time(NULL);
xaccTransSetDateEnteredSecs(gnc_trans, mktime(localtime(&current_time)));
/* Currency; we take simply the default currency of the gnucash account */
xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
/* Currency; we take simply the default currency of the gnucash account */
xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
{
/* Number. We use the "customer reference", if there is one. */
const char *custref = HBCI_Transaction_customerReference (h_trans);
if (custref && (strlen (custref) > 0) &&
(g_strncasecmp (custref, "NONREF", 6) != 0))
xaccTransSetNum (gnc_trans, custref);
}
{
/* Number. We use the "customer reference", if there is one. */
const char *custref = AB_Transaction_GetCustomerReference (h_trans);
if (custref && (strlen (custref) > 0) &&
(g_strncasecmp (custref, "NONREF", 6) != 0))
xaccTransSetNum (gnc_trans, custref);
}
/* Description */
{
char *g_descr = gnc_hbci_descr_tognc (h_trans);
xaccTransSetDescription (gnc_trans, g_descr);
g_free (g_descr);
}
/* Description */
{
char *g_descr = gnc_hbci_descr_tognc (h_trans);
xaccTransSetDescription (gnc_trans, g_descr);
g_free (g_descr);
}
/* Notes. */
/*xaccTransSetNotes (gnc_trans, g_notes);*/
/* But Nobody ever uses the Notes field? */
/* Notes. */
/*xaccTransSetNotes (gnc_trans, g_notes);*/
/* But Nobody ever uses the Notes field? */
/* Add one split */
split=xaccMallocSplit(book);
xaccTransAppendSplit(gnc_trans, split);
xaccAccountInsertSplit(gnc_acc, split);
/* Add one split */
split=xaccMallocSplit(book);
xaccTransAppendSplit(gnc_trans, split);
xaccAccountInsertSplit(gnc_acc, split);
{
/* Amount into the split */
gnc_numeric gnc_amount = double_to_gnc_numeric
(HBCI_Value_getValue (HBCI_Transaction_value (h_trans)),
xaccAccountGetCommoditySCU(gnc_acc),
GNC_RND_ROUND);
{
/* Amount into the split */
gnc_numeric gnc_amount = double_to_gnc_numeric
(AB_Value_GetValue (AB_Transaction_GetValue (h_trans)),
xaccAccountGetCommoditySCU(gnc_acc),
GNC_RND_ROUND);
xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
}
}
/* Memo in the Split. */
{
char *g_memo = gnc_hbci_memo_tognc (h_trans);
xaccSplitSetMemo(split, g_memo);
g_free (g_memo);
}
/* Memo in the Split. */
{
char *g_memo = gnc_hbci_memo_tognc (h_trans);
xaccSplitSetMemo(split, g_memo);
g_free (g_memo);
}
/* Instead of xaccTransCommitEdit(gnc_trans) */
g_assert (data->importer_generic);
gnc_gen_trans_list_add_trans (data->importer_generic, gnc_trans);
/* Instead of xaccTransCommitEdit(gnc_trans) */
g_assert (data->importer_generic);
gnc_gen_trans_list_add_trans (data->importer_generic, gnc_trans);
HBCI_Transaction_delete(h_trans);
}
else if (strcasecmp(GWEN_DB_GroupName(trans_node), "startsaldo")==0) {
/*DBG_INFO(0, "Found opening balance");*/
}
else if (strcasecmp(GWEN_DB_GroupName(trans_node), "endsaldo")==0) {
/* Found closing balance */
trans_node = GWEN_DB_GetGroup(trans_node,
GWEN_PATH_FLAGS_NAMEMUSTEXIST,
"value");
/*if (trans_node) {
HBCI_Value *bal;
char *val;
DBG_INFO(0, "Found closing balance");
bal = HBCI_Value_new(GWEN_DB_GetCharValue(trans_node, "value", 0, "0"),
GWEN_DB_GetCharValue(trans_node, "currency", 0, "EUR"));
val = HBCI_Value_toReadableString(bal);
printf("Got closing balance %s\n", val);
free(val);
HBCI_Value_delete(bal);
}*/
}
else {
/*DBG_WARN(0, "Unknown section \"%s\"", GWEN_DB_GroupName(trans_node));*/
}
return NULL;
}

View File

@@ -24,7 +24,7 @@
#define GNC_HBCI_GETTRANS_H
#include <gnome.h>
#include <openhbci2/outboxjob.h>
#include <aqbanking/jobgettransactions.h>
#include "Account.h"
/** Start a GetTrans job. */
@@ -36,7 +36,7 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc);
gboolean
gnc_hbci_gettrans_final(GtkWidget *parent,
Account *gnc_acc,
const HBCI_OutboxJob *trans_job,
const AB_JOB *trans_job,
gboolean run_until_done);

View File

@@ -25,12 +25,14 @@
#define HBCI_KEY "hbci"
#define HBCI_ACCOUNT_ID "account-id"
#define HBCI_ACCOUNT_UID "account-uid"
#define HBCI_BANK_CODE "bank-code"
#define HBCI_COUNTRY_CODE "country-code"
#define HBCI_TRANS_RETRIEVAL "trans-retrieval"
#define HBCI_ACCOUNTS "hbci-accounts"
/* Account */
#if 0
char *gnc_hbci_get_account_accountid (Account *a)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
@@ -49,12 +51,6 @@ gint gnc_hbci_get_account_countrycode (Account *a)
kvp_value *value = kvp_frame_get_slot (frame, HBCI_COUNTRY_CODE);
return kvp_value_get_gint64 (value);
}
Timespec gnc_hbci_get_account_trans_retrieval (Account *a)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TRANS_RETRIEVAL);
return kvp_value_get_timespec (value);
}
void gnc_hbci_set_account_accountid (Account *a, const char *id)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
@@ -79,6 +75,27 @@ void gnc_hbci_set_account_countrycode (Account *a, gint code)
kvp_frame_set_slot_nc (frame, HBCI_COUNTRY_CODE, value);
xaccAccountCommitEdit (a);
}
#endif
gint gnc_hbci_get_account_uid (Account *a)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNT_UID);
return kvp_value_get_gint64 (value);
}
void gnc_hbci_set_account_uid (Account *a, gint uid)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_value_new_gint64 (uid);
xaccAccountBeginEdit (a);
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_UID, value);
xaccAccountCommitEdit (a);
}
Timespec gnc_hbci_get_account_trans_retrieval (Account *a)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TRANS_RETRIEVAL);
return kvp_value_get_timespec (value);
}
void gnc_hbci_set_account_trans_retrieval (Account *a, Timespec time)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
@@ -121,6 +138,7 @@ void gnc_hbci_set_book_template_list (GNCBook *b, GList *template_list)
qof_book_kvp_changed (b);
}
#if 0
GList *gnc_hbci_get_book_account_list (GNCBook *b)
{
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
@@ -134,6 +152,7 @@ void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list)
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNTS, value);
qof_book_kvp_changed (b);
}
#endif
/* lowlevel */

View File

@@ -30,27 +30,37 @@
/* Account */
/** Returns a non-copied pointer to the accountid string in the
#if 0
/** DEPRECATED. Returns a non-copied pointer to the accountid string in the
* Account a. The char* is still owned by the kvp_frame, so don't free
* it until you want to delete the whole kvp_frame. */
char *gnc_hbci_get_account_accountid (Account *a);
/** Set the accountid string in the Account a. A copy of the string
/** DEPRECATED. Set the accountid string in the Account a. A copy of the string
* will be stored. The Account will be marked as "dirty". */
void gnc_hbci_set_account_accountid (Account *a, const char *id);
/** Returns a non-copied pointer to the bankcode string in the
/** DEPRECATED. Returns a non-copied pointer to the bankcode string in the
* Account a. The char* is still owned by the kvp_frame, so don't free
* it until you want to delete the whole kvp_frame. */
char *gnc_hbci_get_account_bankcode (Account *a);
/** Set the bankcode string in the Account a. A copy of the string
/** DEPRECATED. Set the bankcode string in the Account a. A copy of the string
* will be stored. The Account will be marked as "dirty". */
void gnc_hbci_set_account_bankcode (Account *a, const char *code);
/** Returns the countrycode integer value from the Account a. */
/** DEPRECATED. Returns the countrycode integer value from the Account a. */
gint gnc_hbci_get_account_countrycode (Account *a);
/** Set the countrycode integer value in the Account a. The Account
/** DEPRECATED. Set the countrycode integer value in the Account a. The Account
* will be marked as "dirty". */
void gnc_hbci_set_account_countrycode (Account *a, gint code);
#endif
/** Returns the unique id for the AB_BANKING account in the Account
* a. */
gint gnc_hbci_get_account_uid (Account *a);
/** Set the unique id for the AB_BANKING account in the Account a. The
Account will be marked as "dirty". */
void gnc_hbci_set_account_uid (Account *a, gint uid);
/** Returns the time of last online transaction retrieval */
Timespec gnc_hbci_get_account_trans_retrieval (Account *a);
@@ -75,11 +85,13 @@ void gnc_hbci_set_book_configfile (GNCBook *b, const char *filename);
GList *gnc_hbci_get_book_template_list (GNCBook *b);
void gnc_hbci_set_book_template_list (GNCBook *b, GList *template_list);
#if 0
/** Returns a non-copied pointer to the GList of kvp_frames which
* eventually are the available HBCI accounts, stored in the given
* book. */
GList *gnc_hbci_get_book_account_list (GNCBook *b);
void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list);
#endif
/* lowlevel */

View File

@@ -25,8 +25,7 @@
#include "config.h"
#include "gnc-hbci-transfer.h"
#include <openhbci2/api.h>
#include <openhbci2/outboxjob.h>
#include <aqbanking/banking.h>
#include "gnc-ui.h"
#include "gnc-numeric.h"
@@ -48,24 +47,20 @@ void
gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
GNC_HBCI_Transtype trans_type)
{
HBCI_API *api = NULL;
HBCI_Outbox *outbox = NULL;
const gnc_HBCI_Account *h_acc = NULL;
AB_BANKING *api = NULL;
const AB_ACCOUNT *h_acc = NULL;
GNCInteractor *interactor = NULL;
const HBCI_Customer *customer = NULL;
GList *hbci_accountlist = NULL;
g_assert(parent);
g_assert(gnc_acc);
/* Get API */
api = gnc_hbci_api_new_currentbook (parent, &interactor, &hbci_accountlist);
api = gnc_AB_BANKING_new_currentbook (parent, &interactor);
if (api == NULL) {
printf("gnc_hbci_maketrans: Couldn't get HBCI API. Nothing will happen.\n");
return;
}
g_assert (interactor);
outbox = HBCI_Outbox_new();
/* Get HBCI account */
h_acc = gnc_hbci_get_hbci_acc (api, gnc_acc);
@@ -74,13 +69,8 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
return;
}
/*printf("gnc_hbci_maketrans: HBCI account no. %s found.\n",
gnc_HBCI_Account_accountId (h_acc));*/
AB_ACCOUNT_accountId (h_acc));*/
/* Get the customer that should be doing this job. */
customer = gnc_hbci_get_first_customer(h_acc);
if (!customer)
return;
{
GList *template_list =
gnc_trans_templ_glist_from_kvp_glist
@@ -91,10 +81,10 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
HBCITransDialog *td;
/* Now open the HBCI_trans_dialog, which also calls
HBCI_API_executeQueue. */
AB_BANKING_executeQueue. */
/* Create new HBCIDialogTrans */
td = gnc_hbci_dialog_new(parent, h_acc, customer, gnc_acc,
td = gnc_hbci_dialog_new(parent, h_acc, gnc_acc,
trans_type, template_list);
/* Repeat until HBCI action was successful or user pressed cancel */
@@ -117,9 +107,9 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
gnc_hbci_dialog_hide(td);
{
HBCI_OutboxJob *job =
gnc_hbci_trans_dialog_enqueue(td, api, outbox, customer,
(gnc_HBCI_Account *)h_acc, trans_type);
AB_JOB *job =
gnc_hbci_trans_dialog_enqueue(td, api,
(AB_ACCOUNT *)h_acc, trans_type);
/* HBCI Transaction has been created and enqueued, so now open
* the gnucash transaction dialog and fill in all values. */
@@ -133,7 +123,7 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
/* If the user pressed "execute now", then execute this job
now. This function already delete()s the job. */
successful = gnc_hbci_trans_dialog_execute(td, api, outbox,
successful = gnc_hbci_trans_dialog_execute(td, api,
job, interactor);
if (!successful) {
@@ -163,9 +153,7 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
}*/
/* Just to be on the safe side, clear queue once again. */
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
HBCI_Outbox_delete(outbox);
gnc_hbci_api_save (api);
gnc_AB_BANKING_save (api);
gnc_hbci_dialog_delete(td);
gnc_trans_templ_delete_glist (template_list);
@@ -201,7 +189,7 @@ gnc_hbci_maketrans_final(HBCITransDialog *td, Account *gnc_acc,
{
gnc_numeric amount;
XferDialog *transdialog;
const HBCI_Transaction *h_trans;
const AB_TRANSACTION *h_trans;
gboolean run_until_done = TRUE;
g_assert(td);
@@ -222,7 +210,7 @@ gnc_hbci_maketrans_final(HBCITransDialog *td, Account *gnc_acc,
/* Amount */
amount = double_to_gnc_numeric
(HBCI_Value_getValue (HBCI_Transaction_value (h_trans)),
(AB_Value_GetValue (AB_Transaction_GetValue (h_trans)),
xaccAccountGetCommoditySCU(gnc_acc),
GNC_RND_ROUND);
/*switch (trans_type) {

View File

@@ -24,7 +24,7 @@
#define GNC_HBCI_TRANSFER_H
#include <gnome.h>
#include <openhbci2/transaction.h>
#include <aqbanking/jobsingletransfer.h>
#include "Account.h"
#include "dialog-hbcitrans.h"
@@ -33,7 +33,7 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
GNC_HBCI_Transtype trans_type);
/** Open a gnucash transfer dialog for gnucash Account gnc_acc and
* fill in all the values from the HBCI_Transaction inside the
* fill in all the values from the AB_TRANSACTION inside the
* HBCITransDialog. Returns TRUE if the gnucash transaction has been
* successfully created, FALSE if e.g. the user pressed cancel. */
gboolean

View File

@@ -25,8 +25,6 @@
#include <gnome.h>
#include <errno.h>
#include <openhbci2.h>
#include <openhbci2/error.h>
#include <gwenhywfar/directory.h>
#include "gnc-ui.h"
@@ -39,22 +37,21 @@
/* static short module = MOD_IMPORT; */
/* Globale variables for HBCI_API caching. */
static HBCI_API *gnc_hbci_api = NULL;
/* Globale variables for AB_BANKING caching. */
static AB_BANKING *gnc_AB_BANKING = NULL;
static char *gnc_hbci_configfile = NULL;
static GNCInteractor *gnc_hbci_inter = NULL;
static GList *gnc_hbci_accountlist = NULL;
/* static GList *AB_ACCOUNTlist = NULL; */
/* ------------------------------------------------------------ */
HBCI_API *
gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
GtkWidget *parent, GNCInteractor **inter,
GList **list_accounts)
AB_BANKING *
gnc_AB_BANKING_new (const char *filename, gboolean allowNewFile,
GtkWidget *parent, GNCInteractor **inter)
{
HBCI_API *api = NULL;
HBCI_Error *err = NULL;
char *errstring;
AB_BANKING *api = NULL;
/* int *err = NULL; */
/* char *errstring; */
g_assert(inter);
@@ -77,60 +74,12 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
}
api = HBCI_API_new (FALSE, TRUE);
api = AB_Banking_new ("gnucash", 0);
/* FIXME: The configfile is ignored here */
{
unsigned hbci_major, hbci_minor;
HBCI_Error *er;
er = HBCI_API_configHbciVersion(filename, &hbci_major, &hbci_minor);
if (er) {
HBCI_Error_delete(er);
/* do nothing else; new file */
}
else {
if ((hbci_major == 0) && (hbci_minor == 9)) {
gnc_warning_dialog
(parent,
_(
"The file %s seems to be from a previous version of OpenHBCI.\n"
"With the new version of OpenHBCI, you need to run the HBCI Setup \n"
"Druid again and create a new configuration file before you can work \n"
"with HBCI. You need to create \n"
"your User and Customer in the HBCI Setup Druid, but you can \n"
"directly re-use your existing keyfile or chip card."), filename);
HBCI_API_delete (api);
return NULL;
}
}
}
err = HBCI_API_loadEnvironment (api, filename);
if (!HBCI_Error_isOk (err) && !allowNewFile) {
errstring = HBCI_Error_errorString (err);
HBCI_Error_delete (err);
gnc_warning_dialog
(parent,
/* Translators: Strings from this file are really only needed
* inside Germany (HBCI is not supported anywhere else). You
* may safely ignore strings from the import-export/hbci
* subdirectory in other countries. */
_("Error while loading OpenHBCI config file:\n %s\n"), errstring);
free (errstring);
HBCI_API_delete (api);
return NULL;
}
HBCI_Error_delete (err);
*inter = gnc_hbci_api_interactors (api, parent);
gnc_hbci_accountlist =
gnc_HBCI_Account_glist_from_kvp_glist
(gnc_hbci_get_book_account_list(gnc_get_current_book ()),
api);
if (list_accounts)
*list_accounts = gnc_hbci_accountlist;
*inter = gnc_AB_BANKING_interactors (api, parent);
#if 0
{
/* Well, currently gnucash doesn't offer a way to uniformly ask
for the ~/.gnucash directory, so we have to generate that path
@@ -145,110 +94,95 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
databuffer = g_strjoin("", homebuffer, "/.gnucash/hbci");
/*fprintf(stderr, "Setting log dir to %s\n", databuffer);*/
HBCI_Hbci_setApplicationDataDir(HBCI_API_Hbci(api), databuffer);
/* HBCI_Hbci_setApplicationDataDir(AB_Banking_Hbci(api), databuffer); */
/* FIXME: do we need to set this here? */
g_free(databuffer);
g_free(homebuffer);
}
#endif
return api;
}
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
GNCInteractor **inter,
GList **list_accounts)
AB_BANKING * gnc_AB_BANKING_new_currentbook (GtkWidget *parent,
GNCInteractor **inter)
{
if (gnc_hbci_api == NULL) {
if (gnc_AB_BANKING == NULL) {
/* No API cached -- create new one. */
gnc_hbci_configfile =
g_strdup (gnc_hbci_get_book_configfile (gnc_get_current_book ()));
gnc_hbci_api = gnc_hbci_api_new (gnc_hbci_configfile,
FALSE, parent, &gnc_hbci_inter,
list_accounts);
gnc_AB_BANKING = gnc_AB_BANKING_new (gnc_hbci_configfile,
FALSE, parent, &gnc_hbci_inter);
if (inter)
*inter = gnc_hbci_inter;
return gnc_hbci_api;
return gnc_AB_BANKING;
} else if ((gnc_hbci_configfile != NULL) &&
(strcmp(gnc_hbci_configfile,
gnc_hbci_get_book_configfile (gnc_get_current_book ()))
!= 0)) {
/* Wrong API cached -- delete old and create new. */
gnc_hbci_api_delete (gnc_hbci_api);
gnc_AB_BANKING_delete (gnc_AB_BANKING);
fprintf(stderr,
"gnc_hbci_api_new_currentbook: Wrong HBCI_API cached; creating new one.\n");
return gnc_hbci_api_new_currentbook (parent, inter, list_accounts);
"gnc_AB_BANKING_new_currentbook: Wrong AB_BANKING cached; creating new one.\n");
return gnc_AB_BANKING_new_currentbook (parent, inter);
} else {
/* Correct API cached. */
if (inter) {
*inter = gnc_hbci_inter;
GNCInteractor_reparent (*inter, parent);
}
if (list_accounts)
*list_accounts = gnc_hbci_accountlist;
return gnc_hbci_api;
return gnc_AB_BANKING;
}
}
void gnc_hbci_api_delete (HBCI_API *api)
void gnc_AB_BANKING_delete (AB_BANKING *api)
{
if (api == gnc_hbci_api) {
gnc_hbci_api = NULL;
if (api == gnc_AB_BANKING) {
gnc_AB_BANKING = NULL;
gnc_hbci_inter = NULL;
g_free (gnc_hbci_configfile);
gnc_hbci_configfile = NULL;
list_HBCI_Account_delete (gnc_hbci_accountlist);
gnc_hbci_accountlist = NULL;
}
HBCI_API_delete (api);
if (api == 0)
api = gnc_AB_BANKING;
if (api) {
AB_Banking_Fini(api);
AB_Banking_free(api);
}
}
HBCI_Error * gnc_hbci_api_save (const HBCI_API *api)
int gnc_AB_BANKING_save (const AB_BANKING *api)
{
const char *file = gnc_hbci_get_book_configfile (gnc_get_current_book ());
if ((file == NULL) || (strlen (file) == 0))
return HBCI_Error_new ("gnc_hbci_api_save", ERROR_LEVEL_NORMAL, 0,
ERROR_ADVISE_ABORT,
"No filename for config file in gnc_book.", "");
return HBCI_API_saveEnvironment (api, file);
/* FIXME: do something to save the current state */
return 0;
}
const gnc_HBCI_Account *
gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc)
{
const char *bankcode = NULL, *accountid = NULL;
int countrycode = 0;
const HBCI_Bank *bank;
gnc_HBCI_Account *hbci_acc = NULL;
bankcode = gnc_hbci_get_account_bankcode (gnc_acc);
countrycode = gnc_hbci_get_account_countrycode (gnc_acc);
if (bankcode && (strlen(bankcode)>0) && (countrycode > 0)) {
AB_ACCOUNT *
gnc_hbci_get_hbci_acc (const AB_BANKING *api, Account *gnc_acc)
{
int account_uid = 0;
AB_ACCOUNT *hbci_acc = NULL;
account_uid = gnc_hbci_get_account_uid (gnc_acc);
if (account_uid > 0) {
/*printf("gnc_hbci_get_hbci_acc: gnc_acc %s has blz %s and ccode %d\n",
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
bank = HBCI_API_findBank (api, countrycode, bankcode);
if (bank) {
accountid = gnc_hbci_get_account_accountid (gnc_acc);
/*printf("gnc_hbci_get_hbci_acc: gnc_acc %s found blz %s and ccode %d and accountid %s, bank %p\n",
xaccAccountGetName (gnc_acc), bankcode, countrycode, accountid, bank);*/
if (accountid && (strlen(accountid)>0)) {
hbci_acc = list_HBCI_Account_find(gnc_hbci_accountlist,
bank, bankcode, accountid);
/*printf("gnc_hbci_get_hbci_acc: return HBCI_Account %p\n", hbci_acc);*/
return hbci_acc;
}
}
hbci_acc = AB_Banking_GetAccount(api, account_uid);
/*printf("gnc_hbci_get_hbci_acc: return HBCI_Account %p\n", hbci_acc);*/
return hbci_acc;
}
return NULL;
}
#if 0
static void *
print_list_int_cb (int value, void *user_data)
{
@@ -281,52 +215,29 @@ get_resultcode_error (const list_int *list)
cause = (int) list_int_foreach (list, &get_resultcode_error_cb, &tmp_result);
return MAX(tmp_result, cause);
}
#endif
int
gnc_hbci_debug_outboxjob (HBCI_OutboxJob *job, gboolean verbose)
gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose)
{
list_int *list;
const char *msg;
/* list_int *list; */
/* const char *msg; */
int cause = 0;
g_assert (job);
/* if (HBCI_OutboxJob_status (job) != HBCI_JOB_STATUS_DONE) */
/* if (AB_JOB_status (job) != HBCI_JOB_STATUS_DONE) */
/* return; */
/* if (HBCI_OutboxJob_result (job) != HBCI_JOB_RESULT_FAILED) */
/* if (AB_JOB_result (job) != HBCI_JOB_RESULT_FAILED) */
/* return; */
if (verbose) {
printf("OutboxJob status: ");
switch(HBCI_OutboxJob_status (job)) {
case HBCI_JOB_STATUS_TODO:
printf("todo");
break;
case HBCI_JOB_STATUS_DONE:
printf("done");
break;
default:
case HBCI_JOB_STATUS_NONE:
printf("none");
break;
}
printf("OutboxJob status: %s", AB_Job_Status2Char(AB_Job_GetStatus(job)));
printf(", result: ");
switch(HBCI_OutboxJob_result (job)) {
case HBCI_JOB_RESULT_SUCCESS:
printf("success");
break;
case HBCI_JOB_RESULT_FAILED:
printf("failed");
break;
default:
case HBCI_JOB_STATUS_NONE:
printf("none");
break;
}
printf(", result: %s", AB_Job_GetResultText(job));
printf("\n");
}
list = HBCI_OutboxJob_resultCodes (job);
#if 0
list = AB_JOB_resultCodes (job);
if (list_int_size (list) > 0) {
cause = get_resultcode_error (list);
@@ -358,84 +269,88 @@ gnc_hbci_debug_outboxjob (HBCI_OutboxJob *job, gboolean verbose)
printf("OutboxJob's resultCodes list has zero length.\n");
}
list_int_delete (list);
#endif
return cause;
}
gboolean
gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
gnc_hbci_Error_retry (GtkWidget *parent, int error,
GNCInteractor *inter)
{
int code = HBCI_Error_code (error);
int code = error;
switch (code) {
case HBCI_ERROR_CODE_PIN_WRONG:
#if 0
case AB_ERROR_PIN_WRONG:
GNCInteractor_erasePIN (inter);
return gnc_verify_dialog (parent,
TRUE,
_("The PIN you entered was wrong.\n"
"Do you want to try again?"));
case HBCI_ERROR_CODE_PIN_WRONG_0:
case AB_ERROR_PIN_WRONG_0:
GNCInteractor_erasePIN (inter);
return gnc_verify_dialog (parent,
TRUE,
_("The PIN you entered was wrong.\n"
"ATTENTION: You have zero further wrong retries left!\n"
"Do you want to try again?"));
case HBCI_ERROR_CODE_PIN_WRONG_1:
case AB_ERROR_PIN_WRONG_1:
GNCInteractor_erasePIN (inter);
return gnc_verify_dialog (parent,
TRUE,
_("The PIN you entered was wrong.\n"
"You have one further wrong retry left.\n"
"Do you want to try again?"));
case HBCI_ERROR_CODE_PIN_WRONG_2:
case AB_ERROR_PIN_WRONG_2:
GNCInteractor_erasePIN (inter);
return gnc_verify_dialog (parent,
TRUE,
_("The PIN you entered was wrong.\n"
"You have two further wrong retries left.\n"
"Do you want to try again?"));
case HBCI_ERROR_CODE_PIN_ABORTED:
/* printf("gnc_hbci_error_feedback: PIN dialog was aborted.\n"); */
case AB_ERROR_PIN_ABORTED:
/* printf("gnc_hbci_Error_feedback: PIN dialog was aborted.\n"); */
return FALSE;
case HBCI_ERROR_CODE_PIN_TOO_SHORT:
case AB_ERROR_PIN_TOO_SHORT:
GNCInteractor_erasePIN (inter);
return gnc_verify_dialog (parent,
TRUE,
_("The PIN you entered was too short.\n"
"Do you want to try again?"));
case HBCI_ERROR_CODE_CARD_DESTROYED:
case AB_ERROR_CARD_DESTROYED:
GNCInteractor_hide (inter);
gnc_error_dialog
(parent,
_("Unfortunately you entered a wrong PIN for too many times.\n"
"Your chip card is therefore destroyed. Aborting."));
return FALSE;
case HBCI_ERROR_CODE_FILE_NOT_FOUND:
/* printf("gnc_hbci_error_feedback: File not found error.\n"); */
case AB_ERROR_FILE_NOT_FOUND:
/* printf("gnc_hbci_Error_feedback: File not found error.\n"); */
return FALSE;
case HBCI_ERROR_CODE_NO_CARD:
case AB_ERROR_NO_CARD:
return gnc_verify_dialog (parent,
TRUE,
_("No chip card has been found in the chip card reader.\n"
"Do you want to try again?"));
case HBCI_ERROR_CODE_JOB_NOT_SUPPORTED:
case AB_ERROR_JOB_NOT_SUPPORTED:
GNCInteractor_hide (inter);
gnc_error_dialog
(parent,
_("Unfortunately this HBCI job is not supported \n"
"by your bank or for your account. Aborting."));
return FALSE;
case HBCI_ERROR_CODE_SOCKET_NO_CONNECT:
#endif
case AB_ERROR_NETWORK:
GNCInteractor_hide (inter);
gnc_error_dialog
(parent,
_("The server of your bank refused the HBCI connection.\n"
"Please try again later. Aborting."));
return FALSE;
case HBCI_ERROR_CODE_MEDIUM:
#if 0
case AB_ERROR_MEDIUM:
gnc_error_dialog
(parent,
_("There was an error when loading the plugin for your security medium \n"
@@ -444,13 +359,14 @@ gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
"to recompile and reinstall the plugin again. Aborting now."));
GNCInteractor_hide (inter);
return FALSE;
case HBCI_ERROR_CODE_BAD_MEDIUM:
case AB_ERROR_BAD_MEDIUM:
gnc_error_dialog
(parent,
_("Your security medium is not supported. No appropriate plugin \n"
"has been found for that medium. Aborting."));
GNCInteractor_hide (inter);
return FALSE;
#endif
default:
return FALSE;
@@ -458,6 +374,7 @@ gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
}
#if 0
/* Prints all results that can be found in the outbox into the interactor */
static void gnc_hbci_printresult(HBCI_Outbox *outbox, GNCInteractor *inter)
{
@@ -507,14 +424,22 @@ static void gnc_hbci_printresult(HBCI_Outbox *outbox, GNCInteractor *inter)
GWEN_DB_Group_free(rsp);
}
#endif
static gboolean hbci_Error_isOk(int err) {
switch (err) {
case 0:
return TRUE;
default:
return FALSE;
};
}
gboolean
gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
HBCI_Outbox *queue,
HBCI_OutboxJob *job, GNCInteractor *inter)
gnc_AB_BANKING_execute (GtkWidget *parent, AB_BANKING *api,
AB_JOB *job, GNCInteractor *inter)
{
HBCI_Error *err;
int err;
int resultcode;
if (inter)
@@ -522,33 +447,31 @@ gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
if (gnc_lookup_boolean_option("_+Advanced",
"HBCI Verbose Debug Messages", FALSE)) {
GWEN_Logger_SetLevel(0, GWEN_LoggerLevelDebug);
HBCI_Hbci_setDebugLevel (4);
/* GWEN_Logger_SetLevel(0, GWEN_LoggerLevelDebug); */
/* HBCI_Hbci_setDebugLevel (4); */
}
else
HBCI_Hbci_setDebugLevel (0);
/* else */
/* HBCI_Hbci_setDebugLevel (0); */
do {
if (inter)
GNCInteractor_show_nodelete (inter);
err = HBCI_API_executeQueue (api, queue);
g_assert (err);
err = AB_Banking_ExecuteQueue (api);
/* Print result codes to interactor */
gnc_hbci_printresult(queue, inter);
/* gnc_hbci_printresult(queue, inter); */
} while (gnc_hbci_error_retry (parent, err, inter));
} while (gnc_hbci_Error_retry (parent, err, inter));
resultcode = gnc_hbci_debug_outboxjob (job, FALSE);
if (!HBCI_Error_isOk(err)) {
char *errstr =
g_strdup_printf("gnc_hbci_api_execute: Error at executeQueue: %s",
HBCI_Error_message (err));
printf("%s\n", errstr);
HBCI_Interactor_msgStateResponse (HBCI_Hbci_interactor
(HBCI_API_Hbci (api)), errstr);
g_free (errstr);
HBCI_Error_delete (err);
if (!hbci_Error_isOk(err)) {
/* char *errstr = */
/* g_strdup_printf("gnc_AB_BANKING_execute: Error at executeQueue: %s", */
/* hbci_Error_message (err)); */
/* printf("%s\n", errstr); */
/* HBCI_Interactor_msgStateResponse (HBCI_Hbci_interactor */
/* (AB_BANKING_Hbci (api)), errstr); */
/* g_free (errstr); */
gnc_hbci_debug_outboxjob (job, TRUE);
GNCInteractor_show_nodelete (inter);
return FALSE;
@@ -556,13 +479,11 @@ gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
GNCInteractor_set_cache_valid (inter, TRUE);
if (resultcode <= 20) {
HBCI_Error_delete (err);
return TRUE;
}
else {
printf("gnc_hbci_api_execute: Some message at executeQueue: %s",
HBCI_Error_message (err));
HBCI_Error_delete (err);
/* printf("gnc_AB_BANKING_execute: Some message at executeQueue: %s", */
/* hbci_Error_message (err)); */
GNCInteractor_show_nodelete (inter);
return TRUE; /* <- This used to be a FALSE but this was probably
* as wrong as it could get. @<40>%$! */
@@ -596,7 +517,7 @@ static void *gnc_list_string_cb (const char *string, void *user_data)
}
char *gnc_hbci_descr_tognc (const HBCI_Transaction *h_trans)
char *gnc_hbci_descr_tognc (const AB_TRANSACTION *h_trans)
{
/* Description */
char *h_descr = NULL;
@@ -607,12 +528,12 @@ char *gnc_hbci_descr_tognc (const HBCI_Transaction *h_trans)
g_strstrip every single element of the string list, which is
only done in our callback gnc_list_string_cb. The separator is
also set there. */
list_string_foreach (HBCI_Transaction_description (h_trans),
&gnc_list_string_cb,
&h_descr);
list_string_foreach (HBCI_Transaction_otherName (h_trans),
&gnc_list_string_cb,
&othername);
GWEN_StringList_ForEach (AB_Transaction_GetPurpose (h_trans),
&gnc_list_string_cb,
&h_descr);
GWEN_StringList_ForEach (AB_Transaction_GetRemoteName (h_trans),
&gnc_list_string_cb,
&othername);
/*DEBUG("HBCI Description '%s'", h_descr);*/
if (othername && (strlen (othername) > 0))
@@ -633,16 +554,16 @@ char *gnc_hbci_descr_tognc (const HBCI_Transaction *h_trans)
return g_descr;
}
char *gnc_hbci_memo_tognc (const HBCI_Transaction *h_trans)
char *gnc_hbci_memo_tognc (const AB_TRANSACTION *h_trans)
{
/* Memo in the Split. HBCI's transactionText contains strings like
* "STANDING ORDER", "UEBERWEISUNGSGUTSCHRIFT", etc. */
/* char *h_transactionText = */
/* g_strdup (HBCI_Transaction_transactionText (h_trans)); */
/* g_strdup (AB_TRANSACTION_transactionText (h_trans)); */
char *h_otherAccountId =
g_strdup (HBCI_Transaction_otherAccountId (h_trans));
g_strdup (AB_Transaction_GetRemoteAccountNumber (h_trans));
char *h_otherBankCode =
g_strdup (HBCI_Transaction_otherBankCode (h_trans));
g_strdup (AB_Transaction_GetRemoteBankCode (h_trans));
char *g_memo;
/* g_strstrip (h_transactionText); */
@@ -662,10 +583,11 @@ char *gnc_hbci_memo_tognc (const HBCI_Transaction *h_trans)
}
#if 0
/** Return the only customer that can act on the specified account, or
NULL if none was found. */
const HBCI_Customer *
gnc_hbci_get_first_customer(const gnc_HBCI_Account *h_acc)
gnc_hbci_get_first_customer(const AB_ACCOUNT *h_acc)
{
/* Get one customer. */
const list_HBCI_User *userlist;
@@ -673,7 +595,7 @@ gnc_hbci_get_first_customer(const gnc_HBCI_Account *h_acc)
const HBCI_User *user;
g_assert(h_acc);
bank = gnc_HBCI_Account_bank (h_acc);
bank = AB_ACCOUNT_bank (h_acc);
userlist = HBCI_Bank_users (bank);
g_assert (userlist);
user = choose_one_user(gnc_ui_get_toplevel (), userlist);
@@ -919,3 +841,11 @@ choose_one_user (gncUIWidget parent, const list_HBCI_User *userlist)
g_assert_not_reached();
return NULL;
}
#endif
char *gnc_AB_VALUE_toReadableString(const AB_VALUE *v)
{
char tmp[100];
sprintf(tmp, "%.2f %s", AB_Value_GetValue(v), AB_Value_GetCurrency(v));
return g_strdup(tmp);
}

View File

@@ -25,19 +25,20 @@
#include <glib.h>
#include <gnome.h>
/*#include <openhbci2/account.h>*/
#include <openhbci2/api.h>
#include <openhbci2/transaction.h>
#include <aqbanking/banking.h>
#include <aqbanking/transaction.h>
#include <aqbanking/account.h>
#include "gnc-ui.h"
#include "Account.h"
#include "Transaction.h"
#include "gnc-book.h"
#include "hbci-interaction.h"
#include "gnc-hbci-account.h"
/** Create a new HBCI_API and let it load its environment from the
/** Create a new AB_BANKING and let it load its environment from the
* configuration file filename. If the file doesn't exist and
* allowNewFile is set to FALSE, this function returns NULL. If the
* file exists, but OpenHBCI encountered an error upon opening, then
@@ -49,11 +50,10 @@
* @param inter Reference to a GNCInteractor-pointer in order to use this later.
* May be NULL.
*/
HBCI_API * gnc_hbci_api_new (const char *filename,
AB_BANKING * gnc_AB_BANKING_new (const char *filename,
gboolean allowNewFile,
GtkWidget *parent,
GNCInteractor **inter,
GList **list_accounts);
GNCInteractor **inter);
/** Same as above, but takes the filename already from the current
* book's kvp frame AND caches a pointer to the api. Returns NULL if
@@ -64,75 +64,73 @@ HBCI_API * gnc_hbci_api_new (const char *filename,
* @param inter Reference to a GNCInteractor-pointer in order to use this later.
* May be NULL.
*/
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
GNCInteractor **inter,
GList **list_accounts);
AB_BANKING * gnc_AB_BANKING_new_currentbook (GtkWidget *parent,
GNCInteractor **inter);
/** Delete the given HBCI_API. If this is also the one that was cached
by gnc_hbci_api_new_currentbook, then that reference is deleted, too. */
void gnc_hbci_api_delete (HBCI_API *api);
/** Delete the given AB_BANKING. If this is also the one that was cached
by gnc_AB_BANKING_new_currentbook, then that reference is deleted, too. */
void gnc_AB_BANKING_delete (AB_BANKING *api);
/** Save this API to the config file given in the current book. Return
* an error if one occurred, or if no filename was found in the
/* Save this API to the config file given in the current book. Return
* nonzero if an error occurred, or if no filename was found in the
* current book. */
HBCI_Error * gnc_hbci_api_save (const HBCI_API *api);
int gnc_AB_BANKING_save (const AB_BANKING *api);
/* Get the corresponding HBCI account to a gnucash account. Of course
* this only works after the gnucash account has been set up for HBCI
* use, i.e. the kvp_frame "hbci/..." have been filled with
* information. Returns NULL if no gnc_HBCI_Account was found.
* information. Returns NULL if no AB_ACCOUNT was found.
*
* @param api The HBCI_API to get the gnc_HBCI_Account from.
* @param gnc_acc The gnucash account to query for gnc_HBCI_Account reference data. */
const gnc_HBCI_Account *
gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc);
* @param api The AB_BANKING to get the AB_ACCOUNT from.
* @param gnc_acc The gnucash account to query for AB_ACCOUNT reference data. */
AB_ACCOUNT *
gnc_hbci_get_hbci_acc (const AB_BANKING *api, Account *gnc_acc);
/* Return the HBCI return code of the given 'job', or zero if none was
* found. If 'verbose' is TRUE, make a lot of debugging messages about
* this outboxjob. */
int
gnc_hbci_debug_outboxjob (HBCI_OutboxJob *job, gboolean verbose);
gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose);
/* Check HBCI_Error on whether some feedback should be given to the
/* Check int on whether some feedback should be given to the
* user. Returns true if the HBCI action should be tried again; on the
* other hand, returns false if the user can't do anything about this
* error right now. */
gboolean
gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
gnc_hbci_Error_retry (GtkWidget *parent, int error,
GNCInteractor *inter);
/* Calls HBCI_API_executeQueue with some supplementary stuff around
/* Calls AB_BANKING_executeQueue with some supplementary stuff around
* it: set the debugLevel, show the GNCInteractor, and do some error
* checking. Returns TRUE upon success or FALSE if the calling dialog
* should abort. */
gboolean
gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
HBCI_Outbox *queue,
HBCI_OutboxJob *job, GNCInteractor *inter);
gnc_AB_BANKING_execute (GtkWidget *parent, AB_BANKING *api,
AB_JOB *job, GNCInteractor *inter);
/* Create the appropriate description field for a Gnucash Transaction
* by the information given in the HBCI_Transaction h_trans. The
* by the information given in the AB_TRANSACTION h_trans. The
* returned string must be g_free'd by the caller. */
char *gnc_hbci_descr_tognc (const HBCI_Transaction *h_trans);
char *gnc_hbci_descr_tognc (const AB_TRANSACTION *h_trans);
/* Create the appropriate memo field for a Gnucash Split by the
* information given in the HBCI_Transaction h_trans. The returned
* information given in the AB_TRANSACTION h_trans. The returned
* string must be g_free'd by the caller. */
char *gnc_hbci_memo_tognc (const HBCI_Transaction *h_trans);
char *gnc_hbci_memo_tognc (const AB_TRANSACTION *h_trans);
/** Return the first customer that can act on the specified account,
or NULL if none was found (and an error message is printed on
stdout). */
const HBCI_Customer *
gnc_hbci_get_first_customer(const gnc_HBCI_Account *h_acc);
/* const HBCI_Customer * */
/* gnc_hbci_get_first_customer(const AB_ACCOUNT *h_acc); */
/** Returns the name of this bank. This function is helpful because it
* always makes sure to return a valid const char pointer, even if no
* bankName is available. */
const char *bank_to_str (const HBCI_Bank *bank);
/* const char *bank_to_str (const HBCI_Bank *bank); */
/** Chooses one bank out of the given list.
*
@@ -140,8 +138,8 @@ const char *bank_to_str (const HBCI_Bank *bank);
* dialog so that the user can choose one bank. If the list has only
* one bank, it returns it. If the list has zero banks, it returns
* NULL. */
const HBCI_Bank *
choose_one_bank (gncUIWidget parent, const list_HBCI_Bank *banklist);
/* const HBCI_Bank * */
/* choose_one_bank (gncUIWidget parent, const list_HBCI_Bank *banklist); */
/** Chooses one customer out of the given list.
*
@@ -149,8 +147,8 @@ choose_one_bank (gncUIWidget parent, const list_HBCI_Bank *banklist);
* dialog so that the user can choose one customer. If the list has only
* one customer, it returns it. If the list has zero customers, it returns
* NULL. */
const HBCI_Customer *
choose_one_customer (gncUIWidget parent, const list_HBCI_Customer *custlist);
/* const HBCI_Customer * */
/* choose_one_customer (gncUIWidget parent, const list_HBCI_Customer *custlist); */
/** Chooses one user out of the given list.
*
@@ -158,9 +156,10 @@ choose_one_customer (gncUIWidget parent, const list_HBCI_Customer *custlist);
* dialog so that the user can choose one user. If the list has only
* one user, it returns it. If the list has zero users, it returns
* NULL. */
const HBCI_User *
choose_one_user (gncUIWidget parent, const list_HBCI_User *userlist);
/* const HBCI_User * */
/* choose_one_user (gncUIWidget parent, const list_HBCI_User *userlist); */
/** Return a newly allocated string. */
char *gnc_AB_VALUE_toReadableString(const AB_VALUE *v);
#endif

View File

@@ -16,6 +16,7 @@
#include "gnc-hbci-cb.h"
#include "druid-hbci-initial.h"
#include "gnc-hbci-utils.h"
/* version of the gnc module system interface we require */
int libgncmod_hbci_LTX_gnc_module_system_interface = 0;
@@ -78,6 +79,7 @@ libgncmod_hbci_LTX_gnc_module_init(int refcount)
int
libgncmod_hbci_LTX_gnc_module_end(int refcount) {
gnc_AB_BANKING_delete(0);
return TRUE;
}

View File

@@ -28,7 +28,7 @@
#include "hbci-interaction.h"
#include "hbci-interactionP.h"
#include <openhbci2/interactorcb.h>
#include <aqbanking/banking.h>
#include "dialog-utils.h"
#include "druid-utils.h"
#include "gnc-ui-util.h"
@@ -38,14 +38,12 @@
#include "dialog-pass.h"
#include "gnc-hbci-utils.h"
#include <openhbci2.h>
#define PREF_TAB_ONLINE_BANKING N_("Online Banking & Importing")
/** Adds the interactor and progressmonitor classes to the api. */
GNCInteractor *gnc_hbci_api_interactors (HBCI_API *api, GtkWidget *parent)
GNCInteractor *gnc_AB_BANKING_interactors (AB_BANKING *api, GtkWidget *parent)
{
GNCInteractor *data;
@@ -57,10 +55,11 @@ GNCInteractor *gnc_hbci_api_interactors (HBCI_API *api, GtkWidget *parent)
gnc_lookup_boolean_option(PREF_TAB_ONLINE_BANKING,
"HBCI Remember PIN in memory",
FALSE);
data->showbox_id = 1;
data->showbox_hash = g_hash_table_new(NULL, NULL);
/* set HBCI_Interactor */
HBCI_Hbci_setInteractor(HBCI_API_Hbci(api),
gnc_hbci_new_interactor(data), TRUE);
gnc_hbci_add_callbacks(api, data);
return data;
}
@@ -159,6 +158,8 @@ void GNCInteractor_delete(GNCInteractor *data)
}
data->dialog = NULL;
g_hash_table_destroy(data->showbox_hash);
}
void GNCInteractor_set_cache_valid(GNCInteractor *i, gboolean value)
@@ -174,7 +175,7 @@ void GNCInteractor_erasePIN(GNCInteractor *i)
g_free (memset (i->pw, 0, strlen (i->pw)));
i->pw = NULL;
i->cache_valid = FALSE;
i->user = NULL;
/* i->user = NULL; */
}
void GNCInteractor_reparent (GNCInteractor *i, GtkWidget *new_parent)
{
@@ -194,93 +195,48 @@ void GNCInteractor_reparent (GNCInteractor *i, GtkWidget *new_parent)
/********************************************************
* Now all the callback functions
*/
static const char *username_from_user(const HBCI_User *user)
{
return (user ?
(HBCI_User_name (user) ? HBCI_User_name (user) :
(HBCI_User_userId (user) ? HBCI_User_userId (user) :
_("Unknown"))) :
_("Newly created user"));
}
static int msgInputPin(const HBCI_User *user,
char **pinbuf,
int minsize,
int newPin,
void *user_data)
static int inputBoxCB(AB_BANKING *ab,
GWEN_TYPE_UINT32 flags,
const char *title,
const char *text,
char *resultbuffer,
int minsize,
int maxLen)
{
GNCInteractor *data = user_data;
const HBCI_Bank *bank = NULL;
GNCInteractor *data;
char *msgstr = NULL, *passwd = NULL;
int retval = 0;
int newPin;
int hideInput;
g_assert(ab);
data = /* (GNCInteractor *) */ AB_Banking_GetUserData(ab);
g_assert(data);
g_assert(maxLen > minsize);
newPin = (flags | AB_BANKING_INPUT_FLAGS_CONFIRM) ? TRUE : FALSE;
hideInput = (flags | AB_BANKING_INPUT_FLAGS_SHOW) ? FALSE : TRUE;
if (!hideInput)
printf("inputBoxCB: Oops, hideInput is false -- not implemented.\n");
while (TRUE) {
const char *username = username_from_user(user);
g_assert (username);
if (newPin) {
if (user != NULL) {
bank = HBCI_User_bank (user);
if (bank != NULL) {
/* Translators: Strings from this file are really only
* needed inside Germany (HBCI is not supported anywhere
* else). You may safely ignore strings from the
* import-export/hbci subdirectory in other countries.
*
* xgettext:c-format */
msgstr = g_strdup_printf (_("Please enter and confirm new PIN for \n"
"user '%s' at bank '%s',\n"
"with at least %d characters."),
username,
bank_to_str (bank),
minsize);
}
else
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please enter and confirm a new PIN for \n"
"user '%s',\n"
"with at least %d characters."),
username, minsize);
}
else
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please enter and confirm a new PIN\n"
"with at least %d characters."),
minsize);
if (newPin) {
msgstr = g_strdup_printf("%s\n\n%s", title, text);
retval = gnc_hbci_get_initial_password (data->parent,
msgstr,
&passwd);
g_free (msgstr);
}
else {
if (data->cache_valid && user && (user == data->user)) {
if (data->cache_valid && text && (strcmp(text, data->cache_text)==0)) {
/* Cached user matches, so use cached PIN. */
/*printf("Got the cached PIN for user %s.\n", HBCI_User_userId (user));*/
*pinbuf = g_strdup (data->pw);
strcpy(resultbuffer, data->pw);
return 1;
}
else {
if (user != NULL) {
bank = HBCI_User_bank (user);
if (bank != NULL) {
/* xgettext:c-format */
msgstr = g_strdup_printf (_("Please enter PIN for \n"
"user '%s' at bank '%s'."),
username,
bank_to_str (bank));
}
else {
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please enter PIN for \n"
"user '%s' at unknown bank."),
username);
}
}
else
msgstr = g_strdup ( _("Please enter the PIN for \n"
"the newly created user."));
msgstr = g_strdup_printf("%s\n\n%s", title, text);
retval = gnc_hbci_get_password (data->parent,
msgstr,
@@ -307,10 +263,11 @@ static int msgInputPin(const HBCI_User *user,
break;
}
else {
*pinbuf = g_strdup (passwd);
if (user && data->cache_pin) {
g_assert (maxLen > strlen(resultbuffer));
strcpy(resultbuffer, passwd);
if (text && data->cache_pin) {
/*printf("Cached the PIN for user %s.\n", HBCI_User_userId (user));*/
data->user = user;
data->cache_text = g_strdup(text);
if (data->pw)
g_free (memset (data->pw, 0, strlen (data->pw)));
data->pw = passwd;
@@ -325,155 +282,6 @@ static int msgInputPin(const HBCI_User *user,
return 0;
}
static int msgInsertMediumOrAbort(const HBCI_User *user,
MediumType mtype,
void *user_data)
{
GNCInteractor *data = user_data;
const HBCI_Bank * b = NULL;
char *msgstr = NULL;
GNCVerifyResult retval;
g_assert(data);
if (user != NULL) {
const char *username = username_from_user(user);
b = HBCI_User_bank (user);
switch (mtype)
{
case MediumTypeFile:
if (b != NULL)
/* xgettext:c-format */
msgstr = g_strdup_printf
( _("Please make sure the key file for user '%s' at bank '%s' can be \n"
"accessed. If the key file is on your harddisk, simply press 'Ok'. If \n"
"the key file is on a floppy disk or other removable media, please make \n"
"sure the floppy disk or medium is correctly mounted."),
username, bank_to_str (b));
else
/* xgettext:c-format */
msgstr = g_strdup_printf
( _("Please make sure the key file for user '%s' can be \n"
"accessed. If the key file is on your harddisk, simply press 'Ok'. If \n"
"the key file is on a floppy disk or other removable media, please make \n"
"sure the floppy disk or medium is correctly mounted."),
username);
break;
case MediumTypeCard:
default:
if (b != NULL)
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please insert chip card for \n"
"user '%s' at bank '%s'."),
username, bank_to_str (b));
else
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please insert chip card for \n"
"user '%s'."),
username);
}
}
else
switch (mtype)
{
case MediumTypeFile:
msgstr = g_strdup
(_("Please make sure the key file for the newly created user can be \n"
"accessed. If you want to create the key file on your harddisk, simply \n"
"press 'Ok'. If you want to create the key on a floppy disk or other \n"
"removable media, please make sure the floppy disk or medium is \n"
"correctly mounted."));
break;
case MediumTypeCard:
default:
msgstr = g_strdup ( _("Please insert chip card for \n"
"the newly created user."));
}
retval = gnc_ok_cancel_dialog (data->parent,
GTK_RESPONSE_OK,
"%s", msgstr);
g_free (msgstr);
return (retval == GTK_RESPONSE_OK);
}
static int msgInsertCorrectMediumOrAbort(const HBCI_User *user,
MediumType mtype,
void *user_data)
{
GNCInteractor *data = user_data;
const HBCI_Bank * b = NULL;
char *msgstr = NULL;
GNCVerifyResult retval;
g_assert(data);
if (user != NULL) {
const char *username = username_from_user(user);
b = HBCI_User_bank (user);
switch (mtype)
{
case MediumTypeFile:
if (b != NULL)
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("The key file does not seem to be the correct \n"
"file for user '%s' at bank '%s'. Please make \n"
"sure the correct key file can be accessed."),
username, bank_to_str (b));
else
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("The key file does not seem to be the correct \n"
"file for user '%s'. Please make sure the \n"
"correct key file can be accessed."),
username);
break;
case MediumTypeCard:
default:
if (b != NULL)
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please insert the correct chip card for \n"
"user '%s' at bank '%s'."),
username, bank_to_str (b));
else
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please insert the correct chip card for \n"
"user '%s'."),
username);
}
}
else
switch (mtype)
{
case MediumTypeFile:
msgstr = g_strdup ( _("The key file does not seem to be the correct \n"
"file for the newly created user. Please make \n"
"sure the correct key file can be accessed."));
break;
case MediumTypeCard:
default:
msgstr = g_strdup ( _("Please insert the correct chip card for \n"
"the newly created user."));
}
retval = gnc_ok_cancel_dialog (data->parent,
GTK_RESPONSE_OK,
"%s", msgstr);
g_free (msgstr);
return (retval == GTK_RESPONSE_OK);
}
/*static void msgStateResponse(const char *msg, void *user_data)
{
GNCInteractor *data = user_data;
g_assert(data);
GNCInteractor_add_log_text (data, msg);
while (g_main_iteration (FALSE));
}*/
static int keepAlive(void *user_data)
{
GNCInteractor *data = user_data;
@@ -486,7 +294,8 @@ static int keepAlive(void *user_data)
return data->keepAlive;
}
static void destr(void *user_data)
static void destr(void *bp, void *user_data)
{
GNCInteractor *data = user_data;
if (data == NULL)
@@ -498,203 +307,184 @@ static void destr(void *user_data)
}
}
/* ************************************************************
*/
static void
msgEndInputPinViaKeypadCB(const HBCI_User *user, void *user_data)
hideBoxCB(AB_BANKING *ab, GWEN_TYPE_UINT32 id)
{
GNCInteractor *data = user_data;
GNCInteractor *data;
GtkWidget *dialog;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
if (data->pin_keypad_dialog) {
gnome_dialog_close (GNOME_DIALOG (data->pin_keypad_dialog));
gtk_widget_destroy (data->pin_keypad_dialog);
data->pin_keypad_dialog = NULL;
if (id > 0) {
dialog = g_hash_table_lookup(data->showbox_hash, (gpointer)id);
} else {
dialog = data->showbox_last;
}
if (dialog) {
gnome_dialog_close (GNOME_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_hash_table_remove(data->showbox_hash, (gpointer)id);
}
}
static void
msgStartInputPinViaKeypadCB(const HBCI_User *user, void *user_data)
static GWEN_TYPE_UINT32
showBoxCB(AB_BANKING *ab, GWEN_TYPE_UINT32 flags,
const char *title, const char *text)
{
const HBCI_Bank *bank;
char *msgstr;
GtkWidget *dialog;
GNCInteractor *data = user_data;
GNCInteractor *data;
GWEN_TYPE_UINT32 result;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
/* Already an existing dialog? Shouldn't happen. Better delete
existing dialog first. */
if (data->pin_keypad_dialog != NULL)
msgEndInputPinViaKeypadCB(user, user_data);
/* Create message string */
if (user != NULL) {
const char *username = username_from_user(user);
bank = HBCI_User_bank (user);
if (bank != NULL) {
/* xgettext:c-format */
msgstr = g_strdup_printf (_("Please enter PIN for \n"
"user '%s' at bank '%s'\n"
"at the keypad of your chip card reader."),
username,
bank_to_str (bank));
}
else {
/* xgettext:c-format */
msgstr = g_strdup_printf ( _("Please enter PIN for \n"
"user '%s'\n"
"at the keypad of your chip card reader."),
username);
}
}
else
msgstr = g_strdup ( _("Please enter PIN for \n"
"the newly created user \n"
"at the keypad of your chip card reader."));
msgstr = g_strdup_printf ("%s\n%s", title, text);
/* Create new dialog */
dialog = gnome_ok_dialog_parented (msgstr, GTK_WINDOW (data->parent));
gnome_dialog_close_hides (GNOME_DIALOG(dialog), TRUE);
gtk_widget_show_all (dialog);
data->pin_keypad_dialog = dialog;
result = data->showbox_id;
g_hash_table_insert(data->showbox_hash, (gpointer)result, dialog);
data->showbox_id++;
data->showbox_last = dialog;
g_free (msgstr);
return result;
}
/* ************************************************************
*/
int debug_pmonitor = FALSE;
static int messageBoxCB(AB_BANKING *ab, GWEN_TYPE_UINT32 flags,
const char *title, const char *text,
const char *b1, const char *b2, const char *b3)
{
GNCInteractor *data;
GtkWidget *dialog, *label;
int result;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
/* old ProgressMonitor callbacks
dialog = gnome_dialog_new (title, b1, b2, b3, NULL);
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (data->parent));
gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE);
label = gtk_label_new (text);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0);
result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
if (result<0 || result>2) {
printf("messageBoxCB: Bad result %d", result);
return 0;
}
return result+1;
}
/* ************************************************************
*/
static void actStarted (ActionProgressType type, void *user_data)
#define progress_id 4711
static GWEN_TYPE_UINT32 progressStartCB(AB_BANKING *ab, const char *title,
const char *text, GWEN_TYPE_UINT32 total)
{
GNCInteractor *data = user_data;
const char *msg = NULL;
GNCInteractor *data;
//GtkWidget *dialog;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
switch (type) {
/** Creating HBCI job. Number of Job will follow in string argument. */
case ACT_FILLINGQUEUE:
msg = _("Creating HBCI Job");
break;
/** Contacting server. Server IP address will follow in string argument. */
case ACT_CONTACTINGSERVER:
msg = _("Contacting Server");
break;
/** Checking Job result. */
case ACT_CHKRESULT:
msg = _("Checking Job result");
break;
/** Updating local system. */
case ACT_UPDATESYSTEM:
msg = _("Updating local system");
break;
/** Closing connection. */
case ACT_CLOSECONNECTION:
msg = _("Closing connection");
break;
case ACT_OPENSESSION:
msg = _("Open session");
break;
case ACT_CLOSESESSION:
msg = _("Close session");
break;
case ACT_OPENDIALOG:
msg = _("Open dialog");
break;
case ACT_CLOSEDIALOG:
msg = _("Close dialog");
break;
case ACT_PROCESSMSG:
msg = _("Process message");
break;
case ACT_CREATEJOB:
msg = _("Create job");
break;
case ACT_HANDLEJOBS:
msg = _("Handle jobs");
break;
case ACT_SIGNMSG:
msg = _("Sign message");
break;
case ACT_ENCRYPTMSG:
msg = _("Encrypt message");
break;
case ACT_VERIFYMSG:
msg = _("Verify message");
break;
case ACT_DECRYPTMSG:
msg = _("Decrypt message");
break;
case ACT_ENCODEMSG:
msg = _("Encode message");
break;
case ACT_DECODEMSG:
msg = _("Decode message");
break;
/** Sending message. */
case ACT_SENDINGMESSAGE:
/* Note: the ACT_SENDINGMESSAGE doesn't seem to be used. */
case ACT_LOW_SENDMSG:
msg = _("Sending message");
break;
case ACT_LOW_RECEIVEMSG:
msg = _("Receiving message");
break;
/*default:
msg = _("Unknown");
break;*/
gtk_entry_set_text (GTK_ENTRY (data->job_entry), title);
gtk_entry_set_text (GTK_ENTRY (data->action_entry), text);
/* printf("progressLogCB: Logging msg: %s\n", text); */
/* GNCInteractor_add_log_text (data, text); */
gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress),
0.0);
data->action_max = total;
GNCInteractor_setRunning(data);
GNCInteractor_show(data);
return progress_id;
}
static int progressAdvanceCB(AB_BANKING *ab, GWEN_TYPE_UINT32 id,
GWEN_TYPE_UINT32 progress)
{
GNCInteractor *data;
//GtkWidget *dialog;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
if ((id != 0) || (id != progress_id)) {
printf("progressLogCB: Oops, wrong progress id -- ignored.\n");
}
g_assert(msg);
gtk_entry_set_text (GTK_ENTRY (data->action_entry), msg);
/* Let the widgets be redrawn */
while (g_main_iteration (FALSE));
if (debug_pmonitor)
printf("actStarted-cb: current_job %d, jobs %d, current_act %d, actions %d, msg %s.\n",
data->current_job, data->jobs, data->current_act, data->actions, msg);
GNCInteractor_setRunning (data);
/* Let the widgets be redrawn */
while (g_main_iteration (FALSE));
if (progress != AB_BANKING_PROGRESS_NONE) {
gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress),
progress/data->action_max);
}
keepAlive(data);
return 0;
}
static void closeConnection(TransportType t, void *user_data)
static int progressLogCB(AB_BANKING *ab, GWEN_TYPE_UINT32 id,
AB_BANKING_LOGLEVEL level, const char *text)
{
GNCInteractor *data = user_data;
GNCInteractor *data;
//GtkWidget *dialog;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
data->current_act++;
gtk_entry_set_text (GTK_ENTRY (data->action_entry), _("Done"));
/*gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress),
1.0);*/
if (debug_pmonitor)
printf("actFinished-cb: current_job %d, jobs %d, current_act %d, actions %d.\n",
data->current_job, data->jobs, data->current_act, data->actions);
/*if (data->current_act > data->actions) {
printf("actFinished-cb: oops, current_act==%d is > than actions==%d.\n",
data->current_act, data->actions);
}*/
GNCInteractor_setFinished (data);
while (g_main_iteration (FALSE));
if ((id != 0) || (id != progress_id)) {
printf("progressLogCB: Oops, wrong progress id -- ignored.\n");
}
printf("progressLogCB: Logging msg: %s\n", text);
GNCInteractor_add_log_text (data, text);
keepAlive(data);
return 0;
}
static void logMsg (const char *msg, void *user_data)
static int progressEndCB(AB_BANKING *ab, GWEN_TYPE_UINT32 id)
{
/* Note: this isn't used anyway. */
GNCInteractor *data = user_data;
GNCInteractor *data;
//GtkWidget *dialog;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
printf("logMsg: Logging msg: %s\n", msg);
GNCInteractor_add_log_text (data, msg);
/* Let the widgets be redrawn */
while (g_main_iteration (FALSE));
if ((id != 0) || (id != progress_id)) {
printf("progressLogCB: Oops, wrong progress id -- ignored.\n");
}
GNCInteractor_setFinished(data);
keepAlive(data);
return 0;
}
/* ************************************************************
*/
int debug_pmonitor = FALSE;
void GNCInteractor_add_log_text (GNCInteractor *data, const char *msg)
{
int pos;
@@ -734,14 +524,14 @@ on_button_clicked (GtkButton *button,
while (g_main_iteration (FALSE));
}
GWEN_INHERIT(AB_BANKING, GNCInteractor)
/********************************************************
* Constructor
*/
HBCI_Interactor *
gnc_hbci_new_interactor(GNCInteractor *data)
void
gnc_hbci_add_callbacks(AB_BANKING *ab, GNCInteractor *data)
{
HBCI_InteractorCB *inter;
GtkWidget *dialog;
GladeXML *xml;
@@ -779,8 +569,22 @@ gnc_hbci_new_interactor(GNCInteractor *data)
gtk_object_ref (GTK_OBJECT (dialog));
gtk_widget_hide_all (dialog);
GWEN_INHERIT_SETDATA(AB_BANKING, GNCInteractor,
ab, data,
&destr);
inter = HBCI_InteractorCB_new4(&destr,
AB_Banking_SetMessageBoxFn(ab, messageBoxCB);
AB_Banking_SetInputBoxFn(ab, inputBoxCB);
AB_Banking_SetShowBoxFn(ab, showBoxCB);
AB_Banking_SetHideBoxFn(ab, hideBoxCB);
AB_Banking_SetProgressStartFn(ab, progressStartCB);
AB_Banking_SetProgressAdvanceFn(ab, progressAdvanceCB);
AB_Banking_SetProgressLogFn(ab, progressLogCB);
AB_Banking_SetProgressEndFn(ab, progressEndCB);
AB_Banking_SetUserData(ab, data);
/*inter = HBCI_InteractorCB_new4(&destr,
&msgInputPin,
&msgInsertMediumOrAbort,
&msgInsertCorrectMediumOrAbort,
@@ -791,7 +595,6 @@ gnc_hbci_new_interactor(GNCInteractor *data)
&closeConnection,
&actStarted,
&logMsg,
data);
data);*/
return HBCI_InteractorCB_Interactor(inter);
}

View File

@@ -23,13 +23,13 @@
#ifndef HBCI_INTERACTION_H
#define HBCI_INTERACTION_H
#include <openhbci2/api.h>
#include <aqbanking/banking.h>
#include <gnome.h>
typedef struct _inter_data GNCInteractor;
/** Adds the interactor and progressmonitor classes to the api. */
GNCInteractor *gnc_hbci_api_interactors (HBCI_API *api, GtkWidget *parent);
GNCInteractor *gnc_AB_BANKING_interactors (AB_BANKING *api, GtkWidget *parent);
gboolean GNCInteractor_aborted(const GNCInteractor *i);
void GNCInteractor_show(GNCInteractor *i);

View File

@@ -24,7 +24,7 @@
#ifndef HBCI_INTERACTIONP_H
#define HBCI_INTERACTIONP_H
#include <openhbci2/interactor.h>
#include <aqbanking/banking.h>
#include <gnome.h>
@@ -45,6 +45,7 @@ struct _inter_data
GtkWidget *job_entry;
GtkWidget *action_entry;
GtkWidget *action_progress;
double action_max;
/* Log window */
GtkWidget *log_text;
@@ -75,14 +76,20 @@ struct _inter_data
gboolean cache_pin;
/* The cached PIN and the HBCI_User it's cached for. */
char *pw;
const HBCI_User *user;
char *cache_text;
/* Whether this PIN is really valid or not. */
gboolean cache_valid;
/* Dialogs */
int showbox_id;
GHashTable *showbox_hash;
GtkWidget *showbox_last;
};
void delete_GNCInteractor (GNCInteractor *data);
HBCI_Interactor *
gnc_hbci_new_interactor(GNCInteractor *data);
void
gnc_hbci_add_callbacks(AB_BANKING *ba, GNCInteractor *data);
#endif