mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2004-01-20 Christian Stimming <stimming@tuhh.de>
* configure.in, macros/openhbci2.m4: Add checking for new openhbci2 library. * src/import-export/hbci/ all files: Switch HBCI code to the new openhbci2 library. Should be working, but needs further testing. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9797 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
647a58c824
commit
ddad45fc1c
@ -1,3 +1,11 @@
|
||||
2004-01-20 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* configure.in, macros/openhbci2.m4: Add checking for new
|
||||
openhbci2 library.
|
||||
|
||||
* src/import-export/hbci/ all files: Switch HBCI code to the new
|
||||
openhbci2 library. Should be working, but needs further testing.
|
||||
|
||||
2004-01-20 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/bin/overrides/gnucash-build-env.in: add import-export, ofx,
|
||||
|
@ -589,7 +589,10 @@ AC_ARG_ENABLE( hbci,
|
||||
fi)
|
||||
if test x${HBCI_DIR} = xhbci ;
|
||||
then
|
||||
AM_PATH_OPENHBCI(0.9.13)
|
||||
AM_PATH_OPENHBCI2(1.9.0.1)
|
||||
#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}"
|
||||
|
||||
|
196
macros/openhbci2.m4
Normal file
196
macros/openhbci2.m4
Normal file
@ -0,0 +1,196 @@
|
||||
# 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, µ, &build) != 4)
|
||||
{
|
||||
build = 0;
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 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
|
||||
])
|
@ -8,6 +8,7 @@ libgncmod_hbci_la_SOURCES = \
|
||||
dialog-pass.c \
|
||||
dialog-hbcitrans.c \
|
||||
dialog-daterange.c \
|
||||
gnc-hbci-account.c \
|
||||
gnc-hbci-kvp.c \
|
||||
gnc-hbci-utils.c \
|
||||
gnc-hbci-cb.c \
|
||||
@ -16,7 +17,6 @@ libgncmod_hbci_la_SOURCES = \
|
||||
gnc-hbci-getbalance.c \
|
||||
gnc-hbci-gettrans.c \
|
||||
hbci-interaction.c \
|
||||
hbci-progressmon.c \
|
||||
druid-hbci-initial.c
|
||||
|
||||
# Must be included in tarball because they are listed in POTFILES.in
|
||||
@ -30,6 +30,7 @@ noinst_HEADERS = \
|
||||
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 \
|
||||
|
@ -25,9 +25,8 @@
|
||||
#endif
|
||||
|
||||
#include <gnome.h>
|
||||
#include <openhbci/bank.h>
|
||||
#include <openhbci/outboxaccjobs.h>
|
||||
#include <openhbci.h>
|
||||
#include <openhbci2/bank.h>
|
||||
#include <openhbci2.h>
|
||||
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-ui.h"
|
||||
@ -142,7 +141,7 @@ void gnc_hbci_dialog_show(HBCITransDialog *td)
|
||||
/* -------------------------------------- */
|
||||
|
||||
HBCI_Transaction *
|
||||
hbci_trans_fill_values(const HBCI_Account *h_acc, HBCITransDialog *td);
|
||||
hbci_trans_fill_values(const gnc_HBCI_Account *h_acc, HBCITransDialog *td);
|
||||
gboolean
|
||||
check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
|
||||
const HBCI_Transaction *trans);
|
||||
@ -181,7 +180,7 @@ static void fill_template_menu_func(gpointer data, gpointer user_data)
|
||||
|
||||
HBCITransDialog *
|
||||
gnc_hbci_dialog_new (GtkWidget *parent,
|
||||
const HBCI_Account *h_acc,
|
||||
const gnc_HBCI_Account *h_acc,
|
||||
const HBCI_Customer *customer,
|
||||
Account *gnc_acc,
|
||||
GNC_HBCI_Transtype trans_type,
|
||||
@ -198,7 +197,7 @@ gnc_hbci_dialog_new (GtkWidget *parent,
|
||||
td->trans_type = trans_type;
|
||||
g_assert (h_acc);
|
||||
g_assert (customer);
|
||||
bank = HBCI_Account_bank (h_acc);
|
||||
bank = gnc_HBCI_Account_bank (h_acc);
|
||||
g_assert (bank);
|
||||
#if HAVE_KTOBLZCHECK_H
|
||||
td->blzcheck = AccountNumberCheck_new();
|
||||
@ -319,11 +318,11 @@ 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_custName (customer))>0 ?
|
||||
HBCI_Customer_custName (customer) :
|
||||
(strlen(HBCI_Customer_name (customer)) > 0 ?
|
||||
HBCI_Customer_name (customer) :
|
||||
HBCI_Customer_custId (customer)));
|
||||
gtk_label_set_text (GTK_LABEL (orig_account_label),
|
||||
HBCI_Account_accountId (h_acc));
|
||||
gnc_HBCI_Account_accountId (h_acc));
|
||||
gtk_label_set_text (GTK_LABEL (orig_bankname_label),
|
||||
(strlen(HBCI_Bank_name (bank))>0 ?
|
||||
HBCI_Bank_name (bank) :
|
||||
@ -365,7 +364,7 @@ gnc_hbci_dialog_new (GtkWidget *parent,
|
||||
*/
|
||||
|
||||
int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
|
||||
const HBCI_Account *h_acc)
|
||||
const gnc_HBCI_Account *h_acc)
|
||||
{
|
||||
int result;
|
||||
gboolean values_ok;
|
||||
@ -433,22 +432,19 @@ int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
|
||||
fields into it and return it. The caller must
|
||||
HBCI_Transaction_delete() it when finished. */
|
||||
HBCI_Transaction *
|
||||
hbci_trans_fill_values(const HBCI_Account *h_acc, HBCITransDialog *td)
|
||||
hbci_trans_fill_values(const gnc_HBCI_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();
|
||||
HBCI_Transaction *trans = HBCI_Transaction_new(xnode);
|
||||
|
||||
/* 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_setOurCountryCode (trans,
|
||||
HBCI_Account_countryCode (h_acc));
|
||||
HBCI_Transaction_setOurBankCode (trans,
|
||||
HBCI_Account_instituteCode (h_acc));
|
||||
HBCI_Transaction_setOurAccountId (trans, HBCI_Account_accountId (h_acc));
|
||||
HBCI_Transaction_setOurSuffix (trans, HBCI_Account_accountSuffix (h_acc));
|
||||
gnc_HBCI_Account_bankCode (h_acc));
|
||||
HBCI_Transaction_setOurAccountId (trans, gnc_HBCI_Account_accountId (h_acc));
|
||||
|
||||
HBCI_Transaction_setOtherCountryCode (trans, 280);
|
||||
HBCI_Transaction_setOtherBankCode
|
||||
(trans, gtk_entry_get_text (GTK_ENTRY (td->recp_bankcode_entry)));
|
||||
/* printf("Got otherBankCode %s.\n",
|
||||
@ -530,50 +526,50 @@ check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td,
|
||||
|
||||
HBCI_OutboxJob *
|
||||
gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api,
|
||||
HBCI_Outbox *outbox,
|
||||
const HBCI_Customer *customer,
|
||||
HBCI_Account *h_acc,
|
||||
gnc_HBCI_Account *h_acc,
|
||||
GNC_HBCI_Transtype trans_type)
|
||||
{
|
||||
HBCI_OutboxJob *job;
|
||||
|
||||
const char *jobname;
|
||||
|
||||
/* Create a Do-Transaction (Transfer) job. */
|
||||
switch (trans_type) {
|
||||
case SINGLE_DEBITNOTE:
|
||||
{
|
||||
HBCI_OutboxJobDebitNote *debit_job =
|
||||
HBCI_OutboxJobDebitNote_new (customer, h_acc, td->hbci_trans);
|
||||
job = HBCI_OutboxJobDebitNote_OutboxJob (debit_job);
|
||||
{
|
||||
jobname = "JobSingleDebitNote";
|
||||
}
|
||||
break;
|
||||
case SINGLE_TRANSFER:
|
||||
{
|
||||
HBCI_OutboxJobTransfer *transfer_job =
|
||||
HBCI_OutboxJobTransfer_new (customer, h_acc, td->hbci_trans);
|
||||
job = HBCI_OutboxJobTransfer_OutboxJob (transfer_job);
|
||||
jobname = "JobSingleTransfer";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
/*printf("dialog-hbcitrans: Oops, unknown GNC_HBCI_Transtype %d.\n",
|
||||
trans_type);*/
|
||||
HBCI_OutboxJobTransfer *transfer_job =
|
||||
HBCI_OutboxJobTransfer_new (customer, h_acc, td->hbci_trans);
|
||||
job = HBCI_OutboxJobTransfer_OutboxJob (transfer_job);
|
||||
jobname = "JobSingleTransfer";
|
||||
}
|
||||
}
|
||||
g_assert (job);
|
||||
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));
|
||||
|
||||
/* Make really sure there is no other job in the queue */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
|
||||
/* Add job to queue */
|
||||
HBCI_API_addJob (api, job);
|
||||
HBCI_Outbox_addJob(outbox, job);
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
|
||||
HBCI_Outbox *outbox,
|
||||
HBCI_OutboxJob *job, GNCInteractor *interactor)
|
||||
{
|
||||
gboolean successful;
|
||||
@ -581,7 +577,7 @@ gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
|
||||
g_assert(api);
|
||||
g_assert(job);
|
||||
|
||||
successful = gnc_hbci_api_execute (td->parent, api, job, interactor);
|
||||
successful = gnc_hbci_api_execute (td->parent, api, outbox, job, interactor);
|
||||
|
||||
/*printf("dialog-hbcitrans: Ok, result of api_execute was %d.\n",
|
||||
successful);*/
|
||||
@ -607,7 +603,7 @@ gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
|
||||
}
|
||||
/* Watch out! The job *has* to be removed from the queue
|
||||
here because otherwise it might be executed again. */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
return successful;
|
||||
}
|
||||
|
||||
|
@ -25,14 +25,13 @@
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci/account.h>
|
||||
#include <openhbci/customer.h>
|
||||
#include <openhbci/transaction.h>
|
||||
#include <openhbci/outboxaccjobs.h>
|
||||
#include <openhbci2/api.h>
|
||||
#include <openhbci2/customer.h>
|
||||
#include <openhbci2/transaction.h>
|
||||
#include <openhbci2/outboxjob.h>
|
||||
|
||||
#include "Account.h"
|
||||
#include "hbci-interaction.h"
|
||||
#include "gnc-hbci-utils.h"
|
||||
|
||||
/** The dialog data structure. */
|
||||
typedef struct _trans_data HBCITransDialog;
|
||||
@ -47,7 +46,7 @@ typedef enum GNC_HBCI_Transtype {
|
||||
gnc_hbci_trans (GtkWidget *parent,
|
||||
HBCI_API *api,
|
||||
GNCInteractor *interactor,
|
||||
const HBCI_Account *h_acc,
|
||||
const gnc_HBCI_Account *h_acc,
|
||||
const HBCI_Customer *customer,
|
||||
Account *gnc_acc,
|
||||
GNC_HBCI_Transtype type,
|
||||
@ -57,7 +56,7 @@ gnc_hbci_trans (GtkWidget *parent,
|
||||
* specified by the arguments, and return a pointer to it. */
|
||||
HBCITransDialog *
|
||||
gnc_hbci_dialog_new (GtkWidget *parent,
|
||||
const HBCI_Account *h_acc,
|
||||
const gnc_HBCI_Account *h_acc,
|
||||
const HBCI_Customer *customer,
|
||||
Account *gnc_acc,
|
||||
GNC_HBCI_Transtype trans_type,
|
||||
@ -81,11 +80,12 @@ void gnc_hbci_dialog_show(HBCITransDialog *td);
|
||||
|
||||
|
||||
int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td,
|
||||
const HBCI_Account *h_acc);
|
||||
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,
|
||||
HBCI_Account *h_acc,
|
||||
gnc_HBCI_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. */
|
||||
@ -96,6 +96,7 @@ void gnc_hbci_dialog_xfer_cb(Transaction *trans, gpointer user_data);
|
||||
* enter this job again. */
|
||||
gboolean
|
||||
gnc_hbci_trans_dialog_execute(HBCITransDialog *td, HBCI_API *api,
|
||||
HBCI_Outbox *outbox,
|
||||
HBCI_OutboxJob *job, GNCInteractor *interactor);
|
||||
|
||||
|
||||
|
@ -39,12 +39,11 @@
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-html.h"
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci/outboxjobs.h>
|
||||
#include <openhbci/outboxjobkeys.h>
|
||||
#include <openhbci/mediumrdhbase.h>
|
||||
#include <openhbci2/api.h>
|
||||
#include <openhbci2/outboxjob.h>
|
||||
#include <openhbci2/mediumrdhbase.h>
|
||||
|
||||
#include <openhbci.h>
|
||||
#include <openhbci2.h>
|
||||
|
||||
typedef enum _infostate {
|
||||
INI_ADD_BANK,
|
||||
@ -112,6 +111,8 @@ struct _hbciinitialinfo
|
||||
|
||||
/* OpenHBCI stuff */
|
||||
HBCI_API *api;
|
||||
HBCI_Outbox *outbox;
|
||||
GList *hbci_accountlist;
|
||||
GNCInteractor *interactor;
|
||||
|
||||
/* account match: row_number (int) -> hbci_account */
|
||||
@ -155,6 +156,10 @@ reset_initial_info (HBCIInitialInfo *info)
|
||||
if (info->api != NULL)
|
||||
gnc_hbci_api_delete (info->api);
|
||||
info->api = NULL;
|
||||
if (info->outbox != NULL)
|
||||
HBCI_Outbox_delete(info->outbox);
|
||||
info->outbox = NULL;
|
||||
|
||||
info->newcustomer = NULL;
|
||||
info->newbank = NULL;
|
||||
|
||||
@ -187,7 +192,7 @@ delete_initial_druid (HBCIInitialInfo *info)
|
||||
* update_accountlist widget
|
||||
*/
|
||||
static gpointer
|
||||
update_accountlist_acc_cb (const HBCI_Account *hacc, gpointer user_data)
|
||||
update_accountlist_acc_cb (gnc_HBCI_Account *hacc, gpointer user_data)
|
||||
{
|
||||
HBCIInitialInfo *info = user_data;
|
||||
gchar *row_text[3];
|
||||
@ -202,9 +207,9 @@ update_accountlist_acc_cb (const HBCI_Account *hacc, gpointer user_data)
|
||||
row_text[0] =
|
||||
/* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
|
||||
g_strdup_printf(_("%s at %s (code %s)"),
|
||||
HBCI_Account_accountId (hacc),
|
||||
HBCI_Bank_name (HBCI_Account_bank (hacc)),
|
||||
HBCI_Bank_bankCode (HBCI_Account_bank (hacc)));
|
||||
gnc_HBCI_Account_accountId (hacc),
|
||||
HBCI_Bank_name (gnc_HBCI_Account_bank (hacc)),
|
||||
HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hacc)));
|
||||
|
||||
/* Get corresponding gnucash account */
|
||||
gacc = g_hash_table_lookup (info->gnc_hash, hacc);
|
||||
@ -226,19 +231,10 @@ update_accountlist_acc_cb (const HBCI_Account *hacc, gpointer user_data)
|
||||
/* Store the row_number -> hbci_account hash reference. */
|
||||
row_key = g_new(gint, 1);
|
||||
*row_key = row;
|
||||
g_hash_table_insert (info->hbci_hash, row_key, (HBCI_Account*)hacc);
|
||||
g_hash_table_insert (info->hbci_hash, row_key, (gnc_HBCI_Account*)hacc);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
static gpointer
|
||||
update_accountlist_bank_cb (const HBCI_Bank *bank, gpointer user_data)
|
||||
{
|
||||
g_assert(bank);
|
||||
|
||||
return list_HBCI_Account_foreach (HBCI_Bank_accounts (bank),
|
||||
&update_accountlist_acc_cb,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/* Update the account list GtkCList widget */
|
||||
static void
|
||||
@ -268,10 +264,10 @@ update_accountlist (HBCIInitialInfo *info)
|
||||
info->hbci_hash = g_hash_table_new (&g_int_hash, &g_int_equal);
|
||||
g_hash_table_freeze (info->hbci_hash);
|
||||
|
||||
/* Go through all HBCI banks */
|
||||
list_HBCI_Bank_foreach (banklist,
|
||||
&update_accountlist_bank_cb,
|
||||
info);
|
||||
/* Go through all HBCI accounts */
|
||||
list_HBCI_Account_foreach (info->hbci_accountlist,
|
||||
update_accountlist_acc_cb,
|
||||
info);
|
||||
|
||||
/*printf("HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash));*/
|
||||
/*printf("GNC hash has %d entries.\n", g_hash_table_size(info->gnc_hash));*/
|
||||
@ -426,7 +422,8 @@ static void hbciversion_unselect_row (GtkCList *clist,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
choose_hbciversion_dialog (GtkWindow *parent, HBCI_Bank *bank)
|
||||
choose_hbciversion_dialog (GtkWindow *parent, HBCI_Bank *bank,
|
||||
HBCIInitialInfo *info)
|
||||
{
|
||||
int retval = -1;
|
||||
int selected_row = 0;
|
||||
@ -482,11 +479,21 @@ choose_hbciversion_dialog (GtkWindow *parent, HBCI_Bank *bank)
|
||||
(GTK_CLIST (version_clist), selected_row));
|
||||
if (newversion != initial_selection)
|
||||
{
|
||||
HBCI_OutboxJob *job;
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
/*fprintf (stderr, "Setting new HBCI version %d\n", newversion); */
|
||||
HBCI_Bank_setHbciVersion (bank, newversion);
|
||||
HBCI_Bank_setBPDVersion (bank, 0);
|
||||
gtk_widget_destroy (dialog);
|
||||
/*HBCI_Bank_setBPDVersion (bank, 0);*/
|
||||
job = HBCI_OutboxJob_new("JobUpdateBankInfo",
|
||||
(HBCI_Customer*)info->newcustomer, "");
|
||||
HBCI_Outbox_addJob(info->outbox, job);
|
||||
|
||||
gnome_ok_dialog_parented
|
||||
/* 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. */
|
||||
(_("You have changed the HBCI version. GnuCash will now need to \n"
|
||||
"update various system parameters, including the account list.\n"
|
||||
"Press 'Ok' now to proceed to updating the system and the account list."), parent);
|
||||
@ -517,7 +524,7 @@ static void gnc_hbci_addaccount(HBCIInitialInfo *info,
|
||||
{
|
||||
HBCI_Bank *bank;
|
||||
const HBCI_User *user;
|
||||
HBCI_Account *acc;
|
||||
gnc_HBCI_Account *acc;
|
||||
|
||||
GtkWidget *dlg;
|
||||
char *prompt;
|
||||
@ -530,7 +537,8 @@ static void gnc_hbci_addaccount(HBCIInitialInfo *info,
|
||||
|
||||
/* Ask for new account id by opening a request_dialog -- a druid
|
||||
page would be better from GUI design, but I'm too lazy. */
|
||||
prompt = g_strdup_printf(_("Enter account id for new account \nat bank %s (bank code %s):"),
|
||||
prompt = g_strdup_printf(_("Enter account id for new account \n"
|
||||
"at bank %s (bank code %s):"),
|
||||
HBCI_Bank_name (bank), HBCI_Bank_bankCode (bank));
|
||||
|
||||
dlg = gnome_request_dialog(FALSE, prompt, "", 20,
|
||||
@ -539,25 +547,22 @@ static void gnc_hbci_addaccount(HBCIInitialInfo *info,
|
||||
|
||||
if ((retval == 0) && accnr && (strlen(accnr) > 0)) {
|
||||
|
||||
/* Create the wrapper object */
|
||||
acc = gnc_HBCI_Account_new(bank, HBCI_Bank_bankCode (bank), accnr);
|
||||
|
||||
/* Check if such an account already exists */
|
||||
if ( HBCI_Bank_findAccount (bank, accnr) )
|
||||
if (list_HBCI_Account_foreach(info->hbci_accountlist, hbci_find_acc_cb, acc))
|
||||
{
|
||||
/* Yes, then don't create it again */
|
||||
gnc_HBCI_Account_delete(acc);
|
||||
gnc_error_dialog
|
||||
(info->window,
|
||||
_("An account with this account id at this bank already exists."));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No, then create it now */
|
||||
acc = HBCI_API_accountFactory(bank, accnr, "");
|
||||
/* Add it to the bank, and the bank will also own the newly
|
||||
created object. */
|
||||
HBCI_Bank_addAccount(bank, acc, TRUE);
|
||||
/* and add the given customer as first authorized
|
||||
customer. This needs more work in case there are different
|
||||
customers here. */
|
||||
HBCI_Account_addAuthorizedCustomer(acc, cust);
|
||||
/* No, then add it to our internal list. */
|
||||
info->hbci_accountlist = g_list_append(info->hbci_accountlist, acc);
|
||||
|
||||
/* Don't forget to update the account list, otherwise the new
|
||||
accounts won't show up. */
|
||||
@ -571,6 +576,18 @@ static void gnc_hbci_addaccount(HBCIInitialInfo *info,
|
||||
}
|
||||
/* -------------------------------------- */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* GUI callbacks
|
||||
@ -616,6 +633,13 @@ on_finish (GnomeDruidPage *gnomedruidpage,
|
||||
|
||||
if (info->gnc_hash)
|
||||
accounts_save_kvp (info->gnc_hash);
|
||||
if (info->hbci_accountlist)
|
||||
{
|
||||
GList *kvplist =
|
||||
gnc_HBCI_Account_kvp_glist_from_glist(info->hbci_accountlist);
|
||||
gnc_hbci_set_book_account_list (gnc_get_current_book (), kvplist);
|
||||
}
|
||||
|
||||
|
||||
delete_initial_druid(info);
|
||||
}
|
||||
@ -640,7 +664,7 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
|
||||
/* file doesn't need to be created here since OpenHBCI will create
|
||||
it automatically.*/
|
||||
|
||||
if (!gnc_test_dir_exist_error (info->window, filename)) {
|
||||
if (!gnc_test_dir_exist_error (GTK_WINDOW (info->window), filename)) {
|
||||
g_free (filename);
|
||||
return TRUE;
|
||||
}
|
||||
@ -654,13 +678,15 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
|
||||
/* Create new HBCI_API object, loading its data from filename */
|
||||
info->api = gnc_hbci_api_new (filename, TRUE,
|
||||
GTK_WIDGET (info->window),
|
||||
&(info->interactor));
|
||||
&(info->interactor),
|
||||
&(info->hbci_accountlist));
|
||||
}
|
||||
else if (info->api == NULL)
|
||||
/* Create new HBCI_API object, loading its data from filename */
|
||||
info->api = gnc_hbci_api_new (filename, TRUE,
|
||||
GTK_WIDGET (info->window),
|
||||
&(info->interactor));
|
||||
&(info->interactor),
|
||||
&(info->hbci_accountlist));
|
||||
|
||||
api = info->api;
|
||||
g_free (filename);
|
||||
@ -677,7 +703,9 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* Together with the api, create a new outbox queue */
|
||||
info->outbox = HBCI_Outbox_new();
|
||||
|
||||
/* Get HBCI bank and account list */
|
||||
{
|
||||
const list_HBCI_Bank *banklist;
|
||||
@ -702,7 +730,8 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (HBCI_API_totalAccounts(api) == 0) {
|
||||
if (g_list_length(gnc_hbci_get_book_account_list
|
||||
(gnc_get_current_book ())) == 0) {
|
||||
/* still no accounts? go to account update page*/
|
||||
info->state = INI_UPDATE_ACCOUNTS;
|
||||
info->newcustomer = choose_customer (info);
|
||||
@ -765,7 +794,8 @@ on_bankpage_next (GnomeDruidPage *gnomedruidpage,
|
||||
bank = HBCI_API_findBank(info->api, countrycode, bankcode);
|
||||
if (bank == NULL) {
|
||||
/*printf("on_bankpage_next: Creating bank with code %s.\n", bankcode);*/
|
||||
bank = HBCI_API_bankFactory (info->api, countrycode, bankcode, ipaddr);
|
||||
bank = HBCI_API_bankFactory (info->api, countrycode, bankcode, ipaddr,
|
||||
"");
|
||||
{
|
||||
HBCI_Error *err;
|
||||
err = HBCI_API_addBank (info->api, bank, TRUE);
|
||||
@ -917,7 +947,8 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
|
||||
g_free (mediumname);
|
||||
return TRUE;
|
||||
}
|
||||
if (!gnc_test_dir_exist_error (info->window, mediumname)) {
|
||||
if (!gnc_test_dir_exist_error (GTK_WINDOW (info->window),
|
||||
mediumname)) {
|
||||
g_free (mediumname);
|
||||
return TRUE;
|
||||
}
|
||||
@ -934,7 +965,7 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
|
||||
medium = HBCI_API_createNewMedium (api,
|
||||
mediumtype,
|
||||
FALSE,
|
||||
HBCI_Bank_countryCode (bank),
|
||||
280,
|
||||
HBCI_Bank_bankCode (bank),
|
||||
userid,
|
||||
mediumname, &err);
|
||||
@ -947,8 +978,8 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
newuser = HBCI_API_userFactory (bank, medium, TRUE, userid);
|
||||
HBCI_User_setUserName (newuser, username);
|
||||
newuser = HBCI_API_userFactory (bank, medium, TRUE, userid, username);
|
||||
/*HBCI_User_setUserName (newuser, username);*/
|
||||
/*printf("on_userid_next: Created user with userid %s.\n", userid);*/
|
||||
g_assert(newuser);
|
||||
err = HBCI_Bank_addUser (bank, newuser, TRUE);
|
||||
@ -975,13 +1006,7 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
|
||||
|
||||
{
|
||||
HBCI_Customer *cust;
|
||||
cust = HBCI_API_customerFactory (newuser, customerid,
|
||||
customername ? customername :
|
||||
/* 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. */
|
||||
_("Default Customer"));
|
||||
cust = HBCI_API_customerFactory (newuser, customerid, customername);
|
||||
g_assert (cust);
|
||||
HBCI_User_addCustomer (newuser, cust, TRUE);
|
||||
info->newcustomer = cust;
|
||||
@ -1042,14 +1067,13 @@ on_accountinfo_next (GnomeDruidPage *gnomedruidpage,
|
||||
{
|
||||
/* Execute a Synchronize job, then a GetAccounts job. */
|
||||
HBCI_OutboxJob *job;
|
||||
|
||||
job = HBCI_OutboxJobGetSystemId_OutboxJob
|
||||
(HBCI_OutboxJobGetSystemId_new (info->api,
|
||||
(HBCI_Customer *)info->newcustomer));
|
||||
HBCI_API_addJob (info->api, job);
|
||||
|
||||
job = HBCI_OutboxJob_new("JobSync",
|
||||
(HBCI_Customer *)info->newcustomer, "");
|
||||
HBCI_Outbox_addJob (info->outbox, job);
|
||||
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_hbci_api_execute (info->window, info->api,
|
||||
if (!gnc_hbci_api_execute (info->window, info->api, info->outbox,
|
||||
job, info->interactor)) {
|
||||
/* HBCI_API_executeOutbox failed. */
|
||||
/*return FALSE;*/
|
||||
@ -1057,18 +1081,32 @@ on_accountinfo_next (GnomeDruidPage *gnomedruidpage,
|
||||
}
|
||||
|
||||
/* Now the GetAccounts job. */
|
||||
job = HBCI_OutboxJobGetAccounts_OutboxJob
|
||||
(HBCI_OutboxJobGetAccounts_new ((HBCI_Customer *)info->newcustomer));
|
||||
HBCI_API_addJob (info->api, job);
|
||||
job = HBCI_OutboxJob_new("JobGetAccounts",
|
||||
(HBCI_Customer *)info->newcustomer, "");
|
||||
HBCI_Outbox_addJob (info->outbox, job);
|
||||
|
||||
/*{
|
||||
HBCI_Job *jjob = HBCI_OutboxJob_Job(job);
|
||||
HBCI_Job_setIntProperty("open/ident/country", bank.ref().country());
|
||||
HBCI_Job_setProperty("open/ident/bankcode", bank.ref().bankCode());
|
||||
HBCI_Job_setProperty("open/ident/customerid", c.ref().custId());
|
||||
HBCI_Job_setIntProperty("open/prepare/updversion",0);
|
||||
}*/
|
||||
|
||||
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_hbci_api_execute (info->window, info->api,
|
||||
if (!gnc_hbci_api_execute (info->window, info->api, info->outbox,
|
||||
job, info->interactor)) {
|
||||
/* HBCI_API_executeOutbox failed. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HBCI_API_clearQueueByStatus (info->api, HBCI_JOB_STATUS_NONE);
|
||||
/* Now evaluate the GetAccounts job. FIXME: needs more work */
|
||||
info->hbci_accountlist =
|
||||
gnc_processOutboxResponse(info->api, info->outbox, info->hbci_accountlist);
|
||||
|
||||
/* And clean everything up */
|
||||
HBCI_Outbox_removeByStatus (info->outbox, HBCI_JOB_STATUS_NONE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -1118,7 +1156,7 @@ on_accountlist_select_row (GtkCList *clist, gint row,
|
||||
gpointer user_data)
|
||||
{
|
||||
HBCIInitialInfo *info = user_data;
|
||||
HBCI_Account *hbci_acc;
|
||||
gnc_HBCI_Account *hbci_acc;
|
||||
Account *gnc_acc, *old_value;
|
||||
|
||||
hbci_acc = g_hash_table_lookup (info->hbci_hash, &row);
|
||||
@ -1178,18 +1216,18 @@ on_iniletter_info_next (GnomeDruidPage *gnomedruidpage,
|
||||
/* Execute a GetKey job. */
|
||||
HBCI_OutboxJob *job;
|
||||
|
||||
job = HBCI_OutboxJobGetKeys_OutboxJob
|
||||
(HBCI_OutboxJobGetKeys_new (info->api, info->newcustomer));
|
||||
HBCI_API_addJob (info->api, job);
|
||||
job = HBCI_OutboxJob_new("JobGetKeys",
|
||||
(HBCI_Customer*)info->newcustomer, "");
|
||||
HBCI_Outbox_addJob (info->outbox, job);
|
||||
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_hbci_api_execute (info->window, info->api,
|
||||
if (!gnc_hbci_api_execute (info->window, info->api, info->outbox,
|
||||
job, info->interactor)) {
|
||||
/* HBCI_API_executeOutbox failed. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HBCI_API_clearQueueByStatus (info->api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (info->outbox, HBCI_JOB_STATUS_NONE);
|
||||
info->gotkeysforCustomer = info->newcustomer;
|
||||
|
||||
}
|
||||
@ -1310,18 +1348,18 @@ on_iniletter_userinfo_next (GnomeDruidPage *gnomedruidpage,
|
||||
/* Execute a SendKey job. */
|
||||
HBCI_OutboxJob *job;
|
||||
|
||||
job = HBCI_OutboxJobSendKeys_OutboxJob
|
||||
(HBCI_OutboxJobSendKeys_new (info->api, info->newcustomer));
|
||||
HBCI_API_addJob (info->api, job);
|
||||
job = HBCI_OutboxJob_new("JobSendKeys",
|
||||
(HBCI_Customer*)info->newcustomer, "");
|
||||
HBCI_Outbox_addJob (info->outbox, job);
|
||||
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_hbci_api_execute (info->window, info->api,
|
||||
if (!gnc_hbci_api_execute (info->window, info->api, info->outbox,
|
||||
job, info->interactor)) {
|
||||
/* HBCI_API_executeOutbox failed. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HBCI_API_clearQueueByStatus (info->api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (info->outbox, HBCI_JOB_STATUS_NONE);
|
||||
}
|
||||
else {
|
||||
printf("on_iniletter_userinfo_next: Oops, already got keys for another customer. Not yet implemented.\n");
|
||||
@ -1376,7 +1414,7 @@ on_iniletter_userinfo_next (GnomeDruidPage *gnomedruidpage,
|
||||
"<p> </p>\n"
|
||||
"<hr>\n"
|
||||
"Ort, Datum, Unterschrift</body></html>",
|
||||
HBCI_User_userName (user),
|
||||
HBCI_User_name (user),
|
||||
time_now,
|
||||
HBCI_User_userId (user),
|
||||
keynumber, keyversion,
|
||||
@ -1454,7 +1492,8 @@ on_button_clicked (GtkButton *button,
|
||||
if (choose_hbciversion_dialog
|
||||
(GTK_WINDOW (info->window),
|
||||
(HBCI_Bank *)
|
||||
HBCI_User_bank (HBCI_Customer_user (info->newcustomer))))
|
||||
HBCI_User_bank (HBCI_Customer_user (info->newcustomer)),
|
||||
info))
|
||||
gnome_druid_set_page (GNOME_DRUID (info->druid),
|
||||
GNOME_DRUID_PAGE (info->accountinfopage));
|
||||
} else if (strcmp (name, "updatelist_button") == 0) {
|
||||
@ -1504,6 +1543,7 @@ void gnc_hbci_initial_druid (void)
|
||||
GtkWidget *page;
|
||||
|
||||
info = g_new0 (HBCIInitialInfo, 1);
|
||||
info->hbci_accountlist = NULL;
|
||||
|
||||
xml = gnc_glade_xml_new ("hbci.glade", "HBCI Init Druid");
|
||||
|
||||
@ -1517,6 +1557,7 @@ void gnc_hbci_initial_druid (void)
|
||||
glade_xml_signal_connect_data (xml, "on_cancel",
|
||||
GTK_SIGNAL_FUNC (on_cancel), info);
|
||||
|
||||
|
||||
{
|
||||
/* Page with config file entry widget */
|
||||
page = glade_xml_get_widget(xml, "configfile_page");
|
||||
|
@ -45,10 +45,10 @@
|
||||
/* #include "gnc-gui-query.h" */
|
||||
/* #include "io-example-account.h" */
|
||||
/* #include "top-level.h" */
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci/outboxjobs.h>
|
||||
|
||||
#include <openhbci2/api.h>
|
||||
#include <openhbci2/outboxjob.h>
|
||||
|
||||
#include "gnc-hbci-utils.h"
|
||||
|
||||
/**
|
||||
* Save the reference strings to the HBCI accounts in the kvp's of the
|
||||
@ -56,27 +56,27 @@
|
||||
static void
|
||||
accounts_save_kvp_cb (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
HBCI_Account *hbci_acc = key;
|
||||
gnc_HBCI_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),
|
||||
HBCI_Account_accountId (hbci_acc)) != 0))
|
||||
gnc_HBCI_Account_accountId (hbci_acc)) != 0))
|
||||
gnc_hbci_set_account_accountid
|
||||
(gnc_acc, HBCI_Account_accountId (hbci_acc));
|
||||
(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 (HBCI_Account_bank (hbci_acc))) != 0))
|
||||
HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hbci_acc))) != 0))
|
||||
gnc_hbci_set_account_bankcode
|
||||
(gnc_acc, HBCI_Bank_bankCode (HBCI_Account_bank (hbci_acc)));
|
||||
(gnc_acc, HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hbci_acc)));
|
||||
|
||||
if (gnc_hbci_get_account_countrycode(gnc_acc) !=
|
||||
HBCI_Bank_countryCode (HBCI_Account_bank (hbci_acc)))
|
||||
HBCI_Bank_country (gnc_HBCI_Account_bank (hbci_acc)))
|
||||
gnc_hbci_set_account_countrycode
|
||||
(gnc_acc, HBCI_Bank_countryCode (HBCI_Account_bank (hbci_acc)));
|
||||
(gnc_acc, HBCI_Bank_country (gnc_HBCI_Account_bank (hbci_acc)));
|
||||
}
|
||||
|
||||
/* hash is a DIRECT hash from each HBCI account to each gnucash
|
||||
@ -135,7 +135,7 @@ update_accounts_forbank (GtkWidget *parent, HBCI_API *api,
|
||||
GNCInteractor *inter)
|
||||
{
|
||||
const list_HBCI_User *userlist;
|
||||
list_HBCI_User_iter *begin;
|
||||
const HBCI_User *user;
|
||||
g_assert(bank);
|
||||
|
||||
userlist = HBCI_Bank_users (bank);
|
||||
@ -144,15 +144,8 @@ update_accounts_forbank (GtkWidget *parent, HBCI_API *api,
|
||||
/* Zero users? nothing to do. */
|
||||
return;
|
||||
}
|
||||
else if (list_HBCI_User_size (userlist) == 1) {
|
||||
begin = list_HBCI_User_begin (userlist);
|
||||
update_accounts_foruser (parent, api,
|
||||
list_HBCI_User_iter_get (begin), inter);
|
||||
list_HBCI_User_iter_delete (begin);
|
||||
}
|
||||
else {
|
||||
printf("update_accounts_forbank: Sorry, multiple users not yet supported.\n");
|
||||
}
|
||||
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,
|
||||
@ -160,7 +153,7 @@ update_accounts_foruser (GtkWidget *parent, HBCI_API *api,
|
||||
GNCInteractor *inter)
|
||||
{
|
||||
const list_HBCI_Customer *customerlist;
|
||||
list_HBCI_Customer_iter *begin;
|
||||
const HBCI_Customer *customer;
|
||||
g_assert(user);
|
||||
|
||||
customerlist = HBCI_User_customers (user);
|
||||
@ -169,34 +162,30 @@ update_accounts_foruser (GtkWidget *parent, HBCI_API *api,
|
||||
/* Zero customers? nothing to do. */
|
||||
return;
|
||||
}
|
||||
else if (list_HBCI_Customer_size (customerlist) == 1) {
|
||||
begin = list_HBCI_Customer_begin (customerlist);
|
||||
if (!update_accounts_forcustomer (parent, api,
|
||||
list_HBCI_Customer_iter_get (begin),
|
||||
inter))
|
||||
return;
|
||||
list_HBCI_Customer_iter_delete (begin);
|
||||
}
|
||||
else {
|
||||
printf("update_accounts_foruser: Sorry, multiple customers not yet supported.\n");
|
||||
}
|
||||
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_OutboxJobGetAccounts* get_job;
|
||||
HBCI_OutboxJob *job;
|
||||
HBCI_Outbox *outbox;
|
||||
gboolean result;
|
||||
g_assert(cust);
|
||||
|
||||
/* this const-warning is okay and can be ignored. */
|
||||
get_job = HBCI_OutboxJobGetAccounts_new((HBCI_Customer *)cust);
|
||||
job = HBCI_OutboxJobGetAccounts_OutboxJob(get_job);
|
||||
HBCI_API_addJob(api, job);
|
||||
job = HBCI_OutboxJob_new("JobGetAccounts", (HBCI_Customer *)cust, "");
|
||||
outbox = HBCI_Outbox_new();
|
||||
|
||||
HBCI_Outbox_addJob(outbox, job);
|
||||
|
||||
/* Execute Outbox. */
|
||||
return gnc_hbci_api_execute (parent, api, job, inter);
|
||||
result = gnc_hbci_api_execute (parent, api, outbox, job, inter);
|
||||
|
||||
HBCI_Outbox_delete (outbox);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -213,9 +202,9 @@ static gpointer
|
||||
gnc_hbci_new_hash_from_kvp_cb (Account *gnc_acc, gpointer user_data)
|
||||
{
|
||||
struct hbci_acc_cb_data *data = user_data;
|
||||
HBCI_Account *hbci_acc = NULL;
|
||||
gnc_HBCI_Account *hbci_acc = NULL;
|
||||
|
||||
hbci_acc = (HBCI_Account *) gnc_hbci_get_hbci_acc (data->api, gnc_acc);
|
||||
hbci_acc = (gnc_HBCI_Account *) gnc_hbci_get_hbci_acc (data->api, gnc_acc);
|
||||
if (hbci_acc) {
|
||||
g_hash_table_insert (data->hash, hbci_acc, gnc_acc);
|
||||
}
|
||||
@ -258,14 +247,14 @@ gnc_verify_exist_or_new_file (GtkWidget *parent, const char *filename)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_test_dir_exist_error (GtkWidget *parent, const char *filename)
|
||||
gnc_test_dir_exist_error (GtkWindow *parent, const char *filename)
|
||||
{
|
||||
char *dirname = g_dirname (filename);
|
||||
gboolean dirtest = g_file_test (dirname, G_FILE_TEST_ISDIR);
|
||||
g_free (dirname);
|
||||
if (!dirtest) {
|
||||
gnc_error_dialog
|
||||
(parent,
|
||||
(GTK_WIDGET (parent),
|
||||
_("The directory for file\n"
|
||||
"%s\n"
|
||||
"does not exist. \n"
|
||||
@ -276,3 +265,131 @@ gnc_test_dir_exist_error (GtkWidget *parent, const char *filename)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
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;
|
||||
gnc_HBCI_Account *acc;
|
||||
const char *custid;
|
||||
/*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) {
|
||||
fprintf(stderr, "gnc_processOutboxResponse: AccountData without bank code/account id/customer id");
|
||||
continue;
|
||||
}
|
||||
|
||||
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();*/
|
||||
}
|
||||
|
||||
/* Create new account object */
|
||||
/* FIXME: Store more information here. For now, we stop with
|
||||
this essential information. */
|
||||
acc = gnc_HBCI_Account_new(bank, bankCode, accountId);
|
||||
|
||||
{
|
||||
/* Check if such an account already exists */
|
||||
gnc_HBCI_Account *found_account =
|
||||
list_HBCI_Account_foreach(accountlist, hbci_find_acc_cb, acc);
|
||||
|
||||
if (found_account) {
|
||||
const char *p;
|
||||
|
||||
/* Update account information */
|
||||
printf("Account %d/%s/%s already exists, updating",
|
||||
country, bankCode, accountId);
|
||||
|
||||
p=GWEN_DB_GetCharValue(n, "name", 0, 0);
|
||||
/*if (p)
|
||||
gnc_HBCI_Account_setAccountName(found_account,p);
|
||||
p=GWEN_DB_GetCharValue(n, "customer", 0, 0);
|
||||
if (p)
|
||||
gnc_HBCI_Account_setCustomer(found_account,p);
|
||||
p=GWEN_DB_GetCharValue(n, "currency", 0, 0);
|
||||
if (p)
|
||||
gnc_HBCI_Account_setCurrency(found_account,p);
|
||||
p=GWEN_DB_GetCharValue(n, "name1", 0, 0);
|
||||
if (p)
|
||||
gnc_HBCI_Account_setUserName(found_account,p);*/
|
||||
gnc_HBCI_Account_delete(acc);
|
||||
}
|
||||
else {
|
||||
/* new account already created */
|
||||
|
||||
/* Add it to our internal list. */
|
||||
accountlist = g_list_append(accountlist, acc);
|
||||
|
||||
printf("Added account %d/%s/%s",
|
||||
country, bankCode, accountId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* 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);
|
||||
return accountlist;
|
||||
}
|
||||
|
@ -24,9 +24,9 @@
|
||||
#define DRUID_HBCI_UTILS_H
|
||||
|
||||
#include <gnome.h>
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci2/api.h>
|
||||
#include "hbci-interaction.h"
|
||||
|
||||
#include "gnc-hbci-utils.h"
|
||||
|
||||
/** Save the reference strings to the HBCI accounts in the kvp's of
|
||||
* the gnucash accounts. Each value will only be set if it is
|
||||
@ -52,7 +52,12 @@ gboolean
|
||||
gnc_verify_exist_or_new_file (GtkWidget *parent, const char *filename);
|
||||
|
||||
gboolean
|
||||
gnc_test_dir_exist_error (GtkWidget *parent, const char *filename);
|
||||
gnc_test_dir_exist_error (GtkWindow *parent, const char *filename);
|
||||
|
||||
GList *
|
||||
gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
|
||||
GList *accountlist);
|
||||
|
||||
void *hbci_find_acc_cb(gnc_HBCI_Account *acc, void *user_data);
|
||||
|
||||
#endif
|
||||
|
221
src/import-export/hbci/gnc-hbci-account.c
Normal file
221
src/import-export/hbci/gnc-hbci-account.c
Normal file
@ -0,0 +1,221 @@
|
||||
/********************************************************************\
|
||||
* 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 "hbci-interaction.h"
|
||||
|
||||
/* static short module = MOD_IMPORT; */
|
||||
|
||||
struct _gnc_HBCI_Account
|
||||
{
|
||||
const HBCI_Bank *bank;
|
||||
char *bankCode;
|
||||
char *accountid;
|
||||
};
|
||||
|
||||
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);
|
||||
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 *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 == NULL) return NULL;
|
||||
|
||||
iter = h_list;
|
||||
if (iter->data)
|
||||
res = func_cb(iter->data, user_data);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
for (iter = h_list->next; iter != h_list; iter = iter->next)
|
||||
{
|
||||
if (iter->data)
|
||||
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_free (list_HBCI_Account);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#define HBCI_ACCOUNT_ID "account-id"
|
||||
#define HBCI_BANK_CODE "bank-code"
|
||||
#define HBCI_COUNTRY_CODE "country-code"
|
||||
|
||||
/** 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)) {
|
||||
/*printf("gnc_acc %s has blz %s and ccode %d\n",
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
|
||||
bank = HBCI_API_findBank (api, countrycode, bankcode);
|
||||
res= gnc_HBCI_Account_new(bank,
|
||||
kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_ID)),
|
||||
kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_BANK_CODE)));
|
||||
if (!bank)
|
||||
printf("gnc_HBCI_Account_from_kvp: oops, no bank found.");
|
||||
}
|
||||
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)));
|
||||
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;
|
||||
mydata->res = g_list_append(mydata->res,
|
||||
gnc_HBCI_Account_from_kvp(kvp_value_get_frame(k),
|
||||
mydata->api));
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
|
76
src/import-export/hbci/gnc-hbci-account.h
Normal file
76
src/import-export/hbci/gnc-hbci-account.h
Normal file
@ -0,0 +1,76 @@
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
\********************************************************************/
|
||||
|
||||
#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);
|
||||
/** 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);
|
||||
/** 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);
|
||||
/*@}*/
|
||||
|
||||
/** @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 */
|
@ -22,8 +22,8 @@
|
||||
|
||||
#include "gnc-hbci-actions.h"
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci/outboxaccjobs.h>
|
||||
#include <openhbci2/api.h>
|
||||
#include <openhbci2/outboxaccjobs.h>
|
||||
|
||||
/* File intentionally left blank. */
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "config.h"
|
||||
#include "gnc-hbci-getbalance.h"
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci2/api.h>
|
||||
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-numeric.h"
|
||||
@ -35,19 +35,20 @@
|
||||
#include "dialog-hbcitrans.h"
|
||||
|
||||
|
||||
void gnc_hbci_getbalance_debugprint(HBCI_OutboxJobGetBalance *balance_job,
|
||||
const HBCI_Account *h_acc);
|
||||
void gnc_hbci_getbalance_debugprint(HBCI_OutboxJob *balance_job,
|
||||
const gnc_HBCI_Account *h_acc);
|
||||
|
||||
static void
|
||||
bal_print_debug(const char *name,
|
||||
const HBCI_Value *val,
|
||||
gboolean negative,
|
||||
time_t tt)
|
||||
const char *date_str,
|
||||
const char *time_str)
|
||||
{
|
||||
char *str = HBCI_Value_toReadableString (val);
|
||||
printf("GetBalance: %s%s %s at date %s",
|
||||
printf("GetBalance: %s%s %s at date %s %s",
|
||||
(negative ? "-" : ""), str,
|
||||
name, ctime(&tt));
|
||||
name, date_str, time_str);
|
||||
free (str);
|
||||
}
|
||||
|
||||
@ -56,16 +57,18 @@ void
|
||||
gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
{
|
||||
HBCI_API *api = NULL;
|
||||
const HBCI_Account *h_acc = NULL;
|
||||
HBCI_Outbox *outbox = NULL;
|
||||
const gnc_HBCI_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);
|
||||
api = gnc_hbci_api_new_currentbook (parent, &interactor, &hbci_accountlist);
|
||||
if (api == NULL) {
|
||||
printf("gnc_hbci_getbalance: Couldn't get HBCI API.\n");
|
||||
return;
|
||||
@ -79,7 +82,7 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
return;
|
||||
}
|
||||
/* printf("gnc_hbci_getbalance: HBCI account no. %s found.\n",
|
||||
HBCI_Account_accountId (h_acc)); */
|
||||
gnc_HBCI_Account_accountId (h_acc)); */
|
||||
|
||||
/* Get the customer that should be doing this job. */
|
||||
customer = gnc_hbci_get_first_customer(h_acc);
|
||||
@ -90,22 +93,20 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
|
||||
{
|
||||
/* Execute a GetBalance job. */
|
||||
HBCI_OutboxJobGetBalance *balance_job;
|
||||
HBCI_OutboxJob *job;
|
||||
|
||||
balance_job =
|
||||
HBCI_OutboxJobGetBalance_new (customer, (HBCI_Account *)h_acc);
|
||||
job = HBCI_OutboxJobGetBalance_OutboxJob (balance_job);
|
||||
g_assert (job);
|
||||
|
||||
job = HBCI_OutboxJob_new("JobGetBalance", (HBCI_Customer *)customer,
|
||||
gnc_HBCI_Account_accountId(h_acc));
|
||||
|
||||
/* Add job to API queue */
|
||||
HBCI_API_addJob (api, job);
|
||||
outbox = HBCI_Outbox_new();
|
||||
HBCI_Outbox_addJob (outbox, job);
|
||||
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_hbci_api_execute (parent, api, job, interactor)) {
|
||||
if (!gnc_hbci_api_execute (parent, api, outbox, job, interactor)) {
|
||||
|
||||
/* HBCI_API_executeOutbox failed. */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -114,10 +115,11 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
/* Finish this job. */
|
||||
gnc_hbci_getbalance_finish (parent,
|
||||
gnc_acc,
|
||||
balance_job);
|
||||
job);
|
||||
|
||||
/* Clean up after ourselves. */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_delete(outbox);
|
||||
gnc_hbci_api_save (api);
|
||||
GNCInteractor_hide (interactor);
|
||||
}
|
||||
@ -125,45 +127,53 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
|
||||
|
||||
|
||||
void gnc_hbci_getbalance_debugprint(HBCI_OutboxJobGetBalance *balance_job,
|
||||
const HBCI_Account *h_acc)
|
||||
void gnc_hbci_getbalance_debugprint(HBCI_OutboxJob *job,
|
||||
const gnc_HBCI_Account *h_acc)
|
||||
{
|
||||
const HBCI_AccountBalance *acc_bal;
|
||||
const HBCI_Balance *noted_bal, *booked_bal;
|
||||
time_t balance_tt, noted_tt, booked_tt;
|
||||
|
||||
acc_bal = HBCI_OutboxJobGetBalance_getBalance (balance_job);
|
||||
balance_tt =
|
||||
HBCI_DateTime_to_time_t (HBCI_AccountBalance_date (acc_bal),
|
||||
HBCI_AccountBalance_time (acc_bal));
|
||||
|
||||
booked_bal = HBCI_AccountBalance_bookedBalance (acc_bal);
|
||||
booked_tt = HBCI_DateTime_to_time_t (HBCI_Balance_date (booked_bal),
|
||||
HBCI_Balance_time (booked_bal));
|
||||
|
||||
noted_bal = HBCI_AccountBalance_notedBalance (acc_bal);
|
||||
noted_tt = HBCI_DateTime_to_time_t (HBCI_Balance_date (noted_bal),
|
||||
HBCI_Balance_time (noted_bal));
|
||||
GWEN_DB_NODE *response, *acc_bal;
|
||||
GWEN_DB_NODE *noted_grp, *booked_grp;
|
||||
HBCI_Value *booked_val, *noted_val;
|
||||
/* time_t balance_tt, noted_tt, booked_tt; */
|
||||
|
||||
response = HBCI_Job_responseData(HBCI_OutboxJob_Job(job));
|
||||
if (!response)
|
||||
return;
|
||||
acc_bal =GWEN_DB_GetGroup(response,
|
||||
GWEN_PATH_FLAGS_NAMEMUSTEXIST, "balance");
|
||||
if (!acc_bal)
|
||||
return;
|
||||
|
||||
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"),
|
||||
GWEN_DB_GetCharValue(booked_grp, "currency", 0, "EUR"));
|
||||
noted_val = HBCI_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",
|
||||
HBCI_Account_accountId (h_acc));
|
||||
gnc_HBCI_Account_accountId (h_acc));
|
||||
bal_print_debug("Booked balance",
|
||||
HBCI_Balance_value (booked_bal),
|
||||
HBCI_Balance_isDebit (booked_bal),
|
||||
booked_tt);
|
||||
booked_val,
|
||||
(strcasecmp(GWEN_DB_GetCharValue(booked_grp, "debitmark", 0, "C"),"D")==0),
|
||||
GWEN_DB_GetCharValue(booked_grp, "date", 0, ""),
|
||||
GWEN_DB_GetCharValue(booked_grp, "time", 0, ""));
|
||||
bal_print_debug("Noted balance",
|
||||
HBCI_Balance_value (noted_bal),
|
||||
HBCI_Balance_isDebit (noted_bal),
|
||||
noted_tt);
|
||||
bal_print_debug("Bank Line",
|
||||
HBCI_AccountBalance_bankLine (acc_bal), FALSE,
|
||||
balance_tt);
|
||||
bal_print_debug("Disposable amount",
|
||||
HBCI_AccountBalance_disposable (acc_bal), FALSE,
|
||||
balance_tt);
|
||||
bal_print_debug("Already disposed",
|
||||
HBCI_AccountBalance_disposed (acc_bal), FALSE,
|
||||
balance_tt);
|
||||
noted_val,
|
||||
(strcasecmp(GWEN_DB_GetCharValue(noted_grp, "debitmark", 0, "C"),"D")==0),
|
||||
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, */
|
||||
/* balance_tt); */
|
||||
/* bal_print_debug("Disposable amount", */
|
||||
/* gnc_HBCI_AccountBalance_disposable (acc_bal), FALSE, */
|
||||
/* balance_tt); */
|
||||
/* bal_print_debug("Already disposed", */
|
||||
/* gnc_HBCI_AccountBalance_disposed (acc_bal), FALSE, */
|
||||
/* balance_tt); */
|
||||
HBCI_Value_delete(booked_val);
|
||||
HBCI_Value_delete(noted_val);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
@ -184,33 +194,45 @@ bal_print_balance(const char *format,
|
||||
gboolean
|
||||
gnc_hbci_getbalance_finish (GtkWidget *parent,
|
||||
Account *gnc_acc,
|
||||
const HBCI_OutboxJobGetBalance *balance_job)
|
||||
const HBCI_OutboxJob *job)
|
||||
{
|
||||
const HBCI_AccountBalance *acc_bal;
|
||||
const HBCI_Balance *noted_bal, *booked_bal;
|
||||
const HBCI_Value *booked_val;
|
||||
GWEN_DB_NODE *response, *acc_bal;
|
||||
GWEN_DB_NODE *noted_grp, *booked_grp;
|
||||
HBCI_Value *booked_val, *noted_val;
|
||||
|
||||
time_t booked_tt;
|
||||
/*time_t balance_tt, noted_tt;*/
|
||||
gboolean booked_debit;
|
||||
|
||||
gboolean booked_debit, noted_debit;
|
||||
gboolean dialogres;
|
||||
|
||||
acc_bal = HBCI_OutboxJobGetBalance_getBalance (balance_job);
|
||||
/*balance_tt =
|
||||
HBCI_DateTime_to_time_t (HBCI_AccountBalance_date (acc_bal),
|
||||
HBCI_AccountBalance_time (acc_bal));*/
|
||||
|
||||
booked_bal = HBCI_AccountBalance_bookedBalance (acc_bal);
|
||||
booked_tt = HBCI_DateTime_to_time_t (HBCI_Balance_date (booked_bal),
|
||||
HBCI_Balance_time (booked_bal));
|
||||
booked_val = HBCI_Balance_value (booked_bal);
|
||||
booked_debit = HBCI_Balance_isDebit (booked_bal);
|
||||
response = HBCI_Job_responseData((HBCI_Job*)HBCI_OutboxJob_Job_const(job));
|
||||
if (!response)
|
||||
return TRUE;
|
||||
acc_bal =GWEN_DB_GetGroup(response,
|
||||
GWEN_PATH_FLAGS_NAMEMUSTEXIST, "balance");
|
||||
if (!acc_bal)
|
||||
return TRUE;
|
||||
|
||||
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"),
|
||||
GWEN_DB_GetCharValue(booked_grp, "currency", 0, "EUR"));
|
||||
booked_debit = (strcasecmp(GWEN_DB_GetCharValue(booked_grp, "debitmark", 0, "C"),"D")==0);
|
||||
|
||||
noted_bal = HBCI_AccountBalance_notedBalance (acc_bal);
|
||||
/*noted_tt = HBCI_DateTime_to_time_t (HBCI_Balance_date (noted_bal),
|
||||
HBCI_Balance_time (noted_bal));*/
|
||||
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);
|
||||
|
||||
{
|
||||
HBCI_Date *a = HBCI_Date_new_string(GWEN_DB_GetCharValue(booked_grp, "date", 0, ""), 4);
|
||||
|
||||
if ((HBCI_Value_getValue (HBCI_Balance_value (noted_bal)) == 0) &&
|
||||
(HBCI_Value_getValue (HBCI_Balance_value (booked_bal)) == 0))
|
||||
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))
|
||||
{
|
||||
gnome_ok_dialog_parented
|
||||
/* Translators: Strings from this file are really only
|
||||
@ -239,7 +261,7 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
|
||||
(booked_debit ? "-" : ""),
|
||||
booked_str);
|
||||
char *message2 =
|
||||
((HBCI_Value_getValue (HBCI_Balance_value (noted_bal)) == 0) ?
|
||||
((HBCI_Value_getValue (noted_val) == 0) ?
|
||||
g_strdup_printf("%s", "") :
|
||||
bal_print_balance
|
||||
/* Translators: The first %s is "-" if this amount is
|
||||
@ -247,8 +269,8 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
|
||||
* amount. */
|
||||
(_("For your information: This account also \n"
|
||||
"has a noted balance of %s%s\n"),
|
||||
HBCI_Balance_value (noted_bal),
|
||||
HBCI_Balance_isDebit (noted_bal)));
|
||||
noted_val,
|
||||
noted_debit));
|
||||
const char *message3 = _("Reconcile account now?");
|
||||
|
||||
dialogres = gnc_verify_dialog
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <gnome.h>
|
||||
#include "Account.h"
|
||||
#include <openhbci/outboxaccjobs.h>
|
||||
#include <openhbci2/outboxjob.h>
|
||||
|
||||
/** Starts a GetBalance job, adds the job to the HBCI_API, and
|
||||
* (currently) calls executeOutbox. */
|
||||
@ -37,7 +37,7 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc);
|
||||
gboolean
|
||||
gnc_hbci_getbalance_finish (GtkWidget *parent,
|
||||
Account *gnc_acc,
|
||||
const HBCI_OutboxJobGetBalance *balance_job);
|
||||
const HBCI_OutboxJob *job);
|
||||
|
||||
|
||||
#endif /* GNC_HBCI_GETBALANCE_H */
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "config.h"
|
||||
#include "gnc-hbci-gettrans.h"
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci2/api.h>
|
||||
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-numeric.h"
|
||||
@ -48,7 +48,8 @@ gboolean
|
||||
gettrans_dates(GtkWidget *parent, Account *gnc_acc,
|
||||
HBCI_Date **from_date, HBCI_Date **to_date);
|
||||
|
||||
static void *trans_list_cb (const HBCI_Transaction *trans, void *user_data);
|
||||
static void *trans_list_cb (GWEN_DB_NODE *trans_node, void *user_data);
|
||||
static void *reports_cb(GWEN_DB_NODE *reportn, void *user_data);
|
||||
|
||||
struct trans_list_data
|
||||
{
|
||||
@ -61,20 +62,23 @@ void
|
||||
gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
{
|
||||
HBCI_API *api = NULL;
|
||||
const HBCI_Account *h_acc = NULL;
|
||||
HBCI_Outbox *outbox = NULL;
|
||||
const gnc_HBCI_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);
|
||||
api = gnc_hbci_api_new_currentbook (parent, &interactor, &hbci_accountlist);
|
||||
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 */
|
||||
h_acc = gnc_hbci_get_hbci_acc (api, gnc_acc);
|
||||
@ -83,7 +87,7 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
return;
|
||||
}
|
||||
/* printf("gnc_hbci_gettrans: HBCI account no. %s found.\n",
|
||||
HBCI_Account_accountId (h_acc)); */
|
||||
gnc_HBCI_Account_accountId (h_acc)); */
|
||||
|
||||
/* Get the customer that should be doing this job. */
|
||||
customer = gnc_hbci_get_first_customer(h_acc);
|
||||
@ -96,7 +100,6 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
|
||||
{
|
||||
/* Execute a GetTransactions job. */
|
||||
HBCI_OutboxJobGetTransactions *trans_job;
|
||||
HBCI_OutboxJob *job;
|
||||
Timespec until_timespec;
|
||||
HBCI_Date *from_date, *to_date;
|
||||
@ -108,23 +111,30 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
timespecFromTime_t(&until_timespec, HBCI_Date_to_time_t(to_date));
|
||||
|
||||
/* Create OutboxJob */
|
||||
trans_job =
|
||||
HBCI_OutboxJobGetTransactions_new (customer,
|
||||
(HBCI_Account *)h_acc,
|
||||
from_date,
|
||||
to_date);
|
||||
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 = HBCI_OutboxJobGetTransactions_OutboxJob (trans_job);
|
||||
g_assert (job);
|
||||
|
||||
/* Add job to HBCI_API queue. */
|
||||
HBCI_API_addJob (api, job);
|
||||
HBCI_Outbox_addJob (outbox, job);
|
||||
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_hbci_api_execute (parent, api, job, interactor)) {
|
||||
if (!gnc_hbci_api_execute (parent, api, outbox, job, interactor)) {
|
||||
/* HBCI_API_executeOutbox failed. */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -132,10 +142,11 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
gnc_hbci_set_account_trans_retrieval (gnc_acc, until_timespec);
|
||||
|
||||
/* Now finish the job duties. */
|
||||
gnc_hbci_gettrans_final(parent, gnc_acc, trans_job, FALSE);
|
||||
gnc_hbci_gettrans_final(parent, gnc_acc, job, FALSE);
|
||||
|
||||
/* Clean up behind ourself. */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_delete(outbox);
|
||||
gnc_hbci_api_save (api);
|
||||
GNCInteractor_hide (interactor);
|
||||
}
|
||||
@ -201,17 +212,33 @@ gettrans_dates(GtkWidget *parent, Account *gnc_acc,
|
||||
gboolean
|
||||
gnc_hbci_gettrans_final(GtkWidget *parent,
|
||||
Account *gnc_acc,
|
||||
const HBCI_OutboxJobGetTransactions *trans_job,
|
||||
const HBCI_OutboxJob *trans_job,
|
||||
gboolean run_until_done)
|
||||
{
|
||||
/* Now add the retrieved transactions to the gnucash account. */
|
||||
const list_HBCI_Transaction *trans_list;
|
||||
|
||||
trans_list = HBCI_OutboxJobGetTransactions_transactions (trans_job);
|
||||
/*printf("gnc_hbci_gettrans: Got %d transactions.\n",
|
||||
list_HBCI_Transaction_size(trans_list));*/
|
||||
GWEN_DB_NODE *trans_list, *response;
|
||||
|
||||
if (list_HBCI_Transaction_size(trans_list) > 0) {
|
||||
|
||||
response = HBCI_Job_responseData((HBCI_Job*)HBCI_OutboxJob_Job_const(trans_job));
|
||||
if (!response) {
|
||||
/*printf("Got no responseData\n");*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
trans_list = GWEN_DB_GetGroup(response, GWEN_PATH_FLAGS_NAMEMUSTEXIST,
|
||||
"transactions");
|
||||
if (!trans_list) {
|
||||
gnome_ok_dialog_parented
|
||||
(_("The HBCI import returned no transactions for the selected time period."),
|
||||
GTK_WINDOW (parent));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
trans_list = GWEN_DB_GetGroup(trans_list,
|
||||
GWEN_PATH_FLAGS_NAMEMUSTEXIST,
|
||||
"booked");
|
||||
|
||||
if (trans_list && (GWEN_DB_Groups_Count(trans_list) > 0)) {
|
||||
struct trans_list_data data;
|
||||
GNCImportMainMatcher *importer_generic_gui =
|
||||
gnc_gen_trans_list_new(NULL, NULL, TRUE);
|
||||
@ -219,7 +246,7 @@ gnc_hbci_gettrans_final(GtkWidget *parent,
|
||||
data.importer_generic = importer_generic_gui;
|
||||
data.gnc_acc = gnc_acc;
|
||||
|
||||
list_HBCI_Transaction_foreach (trans_list, trans_list_cb, &data);
|
||||
GWEN_DB_Groups_Foreach (trans_list, reports_cb, &data);
|
||||
|
||||
if (run_until_done)
|
||||
return gnc_gen_trans_list_run (importer_generic_gui);
|
||||
@ -235,102 +262,144 @@ gnc_hbci_gettrans_final(GtkWidget *parent,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 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 (const HBCI_Transaction *h_trans,
|
||||
void *user_data)
|
||||
static void *reports_cb(GWEN_DB_NODE *reportn, void *user_data)
|
||||
{
|
||||
Account *gnc_acc;
|
||||
struct trans_list_data *data = user_data;
|
||||
g_assert(data);
|
||||
g_assert(h_trans);
|
||||
|
||||
gnc_acc = data->gnc_acc;
|
||||
g_assert(gnc_acc);
|
||||
|
||||
gnc_hbci_trans_import(h_trans,data->importer_generic,gnc_acc);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void gnc_hbci_trans_import(const HBCI_Transaction *h_trans,
|
||||
GNCImportMainMatcher *importer_generic,
|
||||
Account *gnc_acc)
|
||||
|
||||
/* 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;
|
||||
GNCBook *book;
|
||||
Transaction *gnc_trans;
|
||||
Split *split;
|
||||
struct trans_list_data *data = user_data;
|
||||
g_assert(data);
|
||||
|
||||
if (!trans_node) return NULL;
|
||||
|
||||
gnc_acc = data->gnc_acc;
|
||||
g_assert(gnc_acc);
|
||||
book = xaccAccountGetBook(gnc_acc);
|
||||
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 (strcasecmp(GWEN_DB_GroupName(trans_node), "transaction")==0) {
|
||||
/* Create wrapper HBCI_Transaction */
|
||||
h_trans = HBCI_Transaction_new(trans_node);
|
||||
|
||||
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));*/
|
||||
gnc_trans = xaccMallocTransaction(book);
|
||||
xaccTransBeginEdit(gnc_trans);
|
||||
|
||||
/*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));*/
|
||||
|
||||
|
||||
/* Date / Time */
|
||||
xaccTransSetDateSecs
|
||||
(gnc_trans, HBCI_Date_to_time_t (HBCI_Transaction_valutaDate (h_trans)));
|
||||
|
||||
current_time = time(NULL);
|
||||
xaccTransSetDateEnteredSecs(gnc_trans, mktime(localtime(¤t_time)));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* 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? */
|
||||
|
||||
/* 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);
|
||||
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);
|
||||
}
|
||||
/* Date / Time */
|
||||
xaccTransSetDateSecs
|
||||
(gnc_trans, HBCI_Date_to_time_t (HBCI_Transaction_valutaDate (h_trans)));
|
||||
|
||||
/* Instead of xaccTransCommitEdit(gnc_trans) */
|
||||
g_assert (importer_generic);
|
||||
gnc_gen_trans_list_add_trans (importer_generic, gnc_trans);
|
||||
current_time = time(NULL);
|
||||
xaccTransSetDateEnteredSecs(gnc_trans, mktime(localtime(¤t_time)));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* 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? */
|
||||
|
||||
/* 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);
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
}
|
||||
|
@ -24,11 +24,8 @@
|
||||
#define GNC_HBCI_GETTRANS_H
|
||||
|
||||
#include <gnome.h>
|
||||
#include <openhbci/outboxaccjobs.h>
|
||||
#include <openhbci/transaction.h>
|
||||
|
||||
#include <openhbci2/outboxjob.h>
|
||||
#include "Account.h"
|
||||
#include "import-main-matcher.h"
|
||||
|
||||
/** Start a GetTrans job. */
|
||||
void
|
||||
@ -39,13 +36,8 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc);
|
||||
gboolean
|
||||
gnc_hbci_gettrans_final(GtkWidget *parent,
|
||||
Account *gnc_acc,
|
||||
const HBCI_OutboxJobGetTransactions *trans_job,
|
||||
const HBCI_OutboxJob *trans_job,
|
||||
gboolean run_until_done);
|
||||
|
||||
/** Import HBCI transaction into gnucash account using importer_generic
|
||||
*/
|
||||
void gnc_hbci_trans_import(const HBCI_Transaction *h_trans,
|
||||
GNCImportMainMatcher *importer_generic,
|
||||
Account *gnc_acc);
|
||||
|
||||
#endif /* GNC_HBCI_GETTRANS_H */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define HBCI_BANK_CODE "bank-code"
|
||||
#define HBCI_COUNTRY_CODE "country-code"
|
||||
#define HBCI_TRANS_RETRIEVAL "trans-retrieval"
|
||||
#define HBCI_ACCOUNTS "hbci-accounts"
|
||||
|
||||
/* Account */
|
||||
char *gnc_hbci_get_account_accountid (Account *a)
|
||||
@ -119,6 +120,20 @@ void gnc_hbci_set_book_template_list (GNCBook *b, GList *template_list)
|
||||
qof_book_kvp_changed (b);
|
||||
}
|
||||
|
||||
GList *gnc_hbci_get_book_account_list (GNCBook *b)
|
||||
{
|
||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNTS);
|
||||
return kvp_value_get_glist (value);
|
||||
}
|
||||
void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list)
|
||||
{
|
||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
||||
kvp_value *value = kvp_value_new_glist_nc (account_list);
|
||||
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNTS, value);
|
||||
qof_book_kvp_changed (b);
|
||||
}
|
||||
|
||||
|
||||
/* lowlevel */
|
||||
/* getters for kvp frame in book */
|
||||
|
@ -75,6 +75,12 @@ 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);
|
||||
|
||||
/** 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);
|
||||
|
||||
/* lowlevel */
|
||||
|
||||
/* internal getter for kvp frame in book */
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "config.h"
|
||||
#include "gnc-hbci-transfer.h"
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci/outboxaccjobs.h>
|
||||
#include <openhbci2/api.h>
|
||||
#include <openhbci2/outboxjob.h>
|
||||
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-numeric.h"
|
||||
@ -47,20 +47,23 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
|
||||
GNC_HBCI_Transtype trans_type)
|
||||
{
|
||||
HBCI_API *api = NULL;
|
||||
const HBCI_Account *h_acc = NULL;
|
||||
HBCI_Outbox *outbox = NULL;
|
||||
const gnc_HBCI_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);
|
||||
api = gnc_hbci_api_new_currentbook (parent, &interactor, &hbci_accountlist);
|
||||
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);
|
||||
@ -69,7 +72,7 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
|
||||
return;
|
||||
}
|
||||
/*printf("gnc_hbci_maketrans: HBCI account no. %s found.\n",
|
||||
HBCI_Account_accountId (h_acc));*/
|
||||
gnc_HBCI_Account_accountId (h_acc));*/
|
||||
|
||||
/* Get the customer that should be doing this job. */
|
||||
customer = gnc_hbci_get_first_customer(h_acc);
|
||||
@ -116,8 +119,8 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
|
||||
|
||||
{
|
||||
HBCI_OutboxJob *job =
|
||||
gnc_hbci_trans_dialog_enqueue(td, api, customer,
|
||||
(HBCI_Account *)h_acc, trans_type);
|
||||
gnc_hbci_trans_dialog_enqueue(td, api, outbox, customer,
|
||||
(gnc_HBCI_Account *)h_acc, trans_type);
|
||||
|
||||
/* HBCI Transaction has been created and enqueued, so now open
|
||||
* the gnucash transaction dialog and fill in all values. */
|
||||
@ -131,7 +134,8 @@ 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, job, interactor);
|
||||
successful = gnc_hbci_trans_dialog_execute(td, api, outbox,
|
||||
job, interactor);
|
||||
|
||||
if (!successful) {
|
||||
/* HBCI job failed -- then remove gnc txn from the books. */
|
||||
@ -160,7 +164,8 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
|
||||
}*/
|
||||
|
||||
/* Just to be on the safe side, clear queue once again. */
|
||||
HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_removeByStatus (outbox, HBCI_JOB_STATUS_NONE);
|
||||
HBCI_Outbox_delete(outbox);
|
||||
gnc_hbci_api_save (api);
|
||||
gnc_hbci_dialog_delete(td);
|
||||
gnc_trans_templ_delete_glist (template_list);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define GNC_HBCI_TRANSFER_H
|
||||
|
||||
#include <gnome.h>
|
||||
#include <openhbci/transaction.h>
|
||||
#include <openhbci2/transaction.h>
|
||||
#include "Account.h"
|
||||
#include "dialog-hbcitrans.h"
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
#include <gnome.h>
|
||||
#include <errno.h>
|
||||
#include <openhbci.h>
|
||||
#include <openhbci/error.h>
|
||||
#include <openhbci2.h>
|
||||
#include <openhbci2/error.h>
|
||||
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-hbci-kvp.h"
|
||||
@ -38,14 +38,20 @@
|
||||
|
||||
/* static short module = MOD_IMPORT; */
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
HBCI_API *
|
||||
gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
GtkWidget *parent, GNCInteractor **inter)
|
||||
GtkWidget *parent, GNCInteractor **inter,
|
||||
GList **list_accounts)
|
||||
{
|
||||
HBCI_API *api = NULL;
|
||||
HBCI_Error *err = NULL;
|
||||
char *errstring;
|
||||
|
||||
g_assert(inter);
|
||||
g_assert(list_accounts);
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
if (!allowNewFile &&
|
||||
@ -53,7 +59,7 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
{
|
||||
/* ENOENT is "No such file or directory" */
|
||||
gchar *errstring = g_strdup_printf ("%s: %s", filename, strerror (ENOENT));
|
||||
gnc_warning_dialog
|
||||
gnc_warning_dialog
|
||||
(parent,
|
||||
/* Translators: Strings from this file are really only needed
|
||||
* inside Germany (HBCI is not supported anywhere else). You
|
||||
@ -67,11 +73,37 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
|
||||
api = HBCI_API_new (FALSE, TRUE);
|
||||
|
||||
{
|
||||
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
|
||||
gnc_warning_dialog
|
||||
(parent,
|
||||
/* Translators: Strings from this file are really only needed
|
||||
* inside Germany (HBCI is not supported anywhere else). You
|
||||
@ -84,10 +116,12 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
}
|
||||
HBCI_Error_delete (err);
|
||||
|
||||
if (inter)
|
||||
*inter = gnc_hbci_api_interactors (api, parent);
|
||||
else
|
||||
gnc_hbci_api_interactors (api, parent);
|
||||
*inter = gnc_hbci_api_interactors (api, parent);
|
||||
|
||||
*list_accounts =
|
||||
gnc_HBCI_Account_glist_from_kvp_glist
|
||||
(gnc_hbci_get_book_account_list(gnc_get_current_book ()),
|
||||
api);
|
||||
|
||||
return api;
|
||||
}
|
||||
@ -95,31 +129,46 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
static HBCI_API *gnc_hbci_api = NULL;
|
||||
static char *gnc_hbci_configfile = NULL;
|
||||
static GNCInteractor *gnc_hbci_inter = NULL;
|
||||
static GList *gnc_hbci_accountlist = NULL;
|
||||
|
||||
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
|
||||
GNCInteractor **inter)
|
||||
GNCInteractor **inter,
|
||||
GList **list_accounts)
|
||||
{
|
||||
if (gnc_hbci_api == 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, inter);
|
||||
gnc_hbci_inter = *inter;
|
||||
FALSE, parent, &gnc_hbci_inter,
|
||||
&gnc_hbci_accountlist);
|
||||
if (inter)
|
||||
*inter = gnc_hbci_inter;
|
||||
|
||||
/* Retrieve the stored list of HBCI accounts */
|
||||
if (list_accounts)
|
||||
*list_accounts = gnc_hbci_accountlist;
|
||||
|
||||
return gnc_hbci_api;
|
||||
|
||||
} else if ((gnc_hbci_configfile != NULL) &&
|
||||
(strcmp(gnc_hbci_configfile,
|
||||
gnc_hbci_get_book_configfile (gnc_get_current_book ()))
|
||||
!= 0)) {
|
||||
!= 0)) {
|
||||
/* Wrong API cached -- delete old and create new. */
|
||||
gnc_hbci_api_delete (gnc_hbci_api);
|
||||
fprintf(stderr,
|
||||
"gnc_hbci_api_new_currentbook: Wrong HBCI_API cached; creating new one.\n");
|
||||
return gnc_hbci_api_new_currentbook (parent, inter);
|
||||
return gnc_hbci_api_new_currentbook (parent, inter, list_accounts);
|
||||
} else {
|
||||
/* Correct API cached. */
|
||||
*inter = gnc_hbci_inter;
|
||||
GNCInteractor_reparent (*inter, parent);
|
||||
if (inter) {
|
||||
*inter = gnc_hbci_inter;
|
||||
GNCInteractor_reparent (*inter, parent);
|
||||
}
|
||||
if (list_accounts)
|
||||
*list_accounts = gnc_hbci_accountlist;
|
||||
|
||||
return gnc_hbci_api;
|
||||
}
|
||||
}
|
||||
@ -131,6 +180,8 @@ void gnc_hbci_api_delete (HBCI_API *api)
|
||||
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);
|
||||
}
|
||||
@ -149,13 +200,13 @@ HBCI_Error * gnc_hbci_api_save (const HBCI_API *api)
|
||||
|
||||
|
||||
|
||||
const HBCI_Account *
|
||||
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 = NULL;
|
||||
const HBCI_Account *hbci_acc = NULL;
|
||||
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);
|
||||
@ -164,18 +215,15 @@ gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc)
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
|
||||
bank = HBCI_API_findBank (api, countrycode, bankcode);
|
||||
if (bank) {
|
||||
/*printf("gnc_acc %s has blz %s and ccode %d\n",
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
|
||||
accountid = gnc_hbci_get_account_accountid (gnc_acc);
|
||||
if (accountid && (strlen(accountid)>0)) {
|
||||
hbci_acc = HBCI_Bank_findAccount (bank, accountid);
|
||||
if (hbci_acc) {
|
||||
/*printf("can connect gnc_acc %s to hbci_acc %s\n",
|
||||
xaccAccountGetName (gnc_acc),
|
||||
HBCI_Account_accountId (hbci_acc));*/
|
||||
return hbci_acc;
|
||||
} /* hbci_acc */
|
||||
} /* accountid */
|
||||
} /* bank */
|
||||
} /* bankcode */
|
||||
hbci_acc = gnc_HBCI_Account_new(bank, bankcode, accountid);
|
||||
return hbci_acc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -304,39 +352,39 @@ gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
|
||||
case HBCI_ERROR_CODE_PIN_WRONG:
|
||||
GNCInteractor_erasePIN (inter);
|
||||
return gnc_verify_dialog (parent,
|
||||
TRUE,
|
||||
_("The PIN you entered was wrong.\n"
|
||||
"Do you want to try again?"));
|
||||
TRUE,
|
||||
_("The PIN you entered was wrong.\n"
|
||||
"Do you want to try again?"));
|
||||
case HBCI_ERROR_CODE_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?"));
|
||||
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:
|
||||
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?"));
|
||||
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:
|
||||
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?"));
|
||||
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"); */
|
||||
return FALSE;
|
||||
case HBCI_ERROR_CODE_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?"));
|
||||
TRUE,
|
||||
_("The PIN you entered was too short.\n"
|
||||
"Do you want to try again?"));
|
||||
case HBCI_ERROR_CODE_CARD_DESTROYED:
|
||||
GNCInteractor_hide (inter);
|
||||
gnc_error_dialog
|
||||
@ -349,12 +397,12 @@ gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
|
||||
return FALSE;
|
||||
case HBCI_ERROR_CODE_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?"));
|
||||
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:
|
||||
GNCInteractor_hide (inter);
|
||||
gnc_error_dialog
|
||||
gnc_error_dialog
|
||||
(parent,
|
||||
_("Unfortunately this HBCI job is not supported \n"
|
||||
"by your bank or for your account. Aborting."));
|
||||
@ -391,6 +439,7 @@ gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
|
||||
|
||||
gboolean
|
||||
gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
|
||||
HBCI_Outbox *queue,
|
||||
HBCI_OutboxJob *job, GNCInteractor *inter)
|
||||
{
|
||||
HBCI_Error *err;
|
||||
@ -406,7 +455,9 @@ gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
|
||||
HBCI_Hbci_setDebugLevel (0);
|
||||
|
||||
do {
|
||||
err = HBCI_API_executeQueue (api, TRUE);
|
||||
if (inter)
|
||||
GNCInteractor_show_nodelete (inter);
|
||||
err = HBCI_API_executeQueue (api, queue);
|
||||
g_assert (err);
|
||||
} while (gnc_hbci_error_retry (parent, err, inter));
|
||||
|
||||
@ -508,31 +559,25 @@ char *gnc_hbci_memo_tognc (const HBCI_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));
|
||||
/* char *h_transactionText = */
|
||||
/* g_strdup (HBCI_Transaction_transactionText (h_trans)); */
|
||||
char *h_otherAccountId =
|
||||
g_strdup (HBCI_Transaction_otherAccountId (h_trans));
|
||||
char *h_otherBankCode =
|
||||
g_strdup (HBCI_Transaction_otherBankCode (h_trans));
|
||||
char *g_memo;
|
||||
|
||||
g_strstrip (h_transactionText);
|
||||
/* g_strstrip (h_transactionText); */
|
||||
g_strstrip (h_otherAccountId);
|
||||
g_strstrip (h_otherBankCode);
|
||||
|
||||
g_memo =
|
||||
(h_transactionText && (strlen(h_transactionText) > 0) ?
|
||||
g_strdup_printf ("%s %s %s %s %s",
|
||||
h_transactionText,
|
||||
(h_otherAccountId && (strlen (h_otherAccountId) > 0) ?
|
||||
g_strdup_printf ("%s %s %s %s",
|
||||
_("Account"), h_otherAccountId,
|
||||
_("Bank"), h_otherBankCode) :
|
||||
(h_otherAccountId && (strlen (h_otherAccountId) > 0) ?
|
||||
g_strdup_printf ("%s %s %s %s",
|
||||
_("Account"), h_otherAccountId,
|
||||
_("Bank"), h_otherBankCode) :
|
||||
g_strdup ("")));
|
||||
g_strdup (""));
|
||||
|
||||
g_free (h_transactionText);
|
||||
g_free (h_otherAccountId);
|
||||
g_free (h_otherBankCode);
|
||||
return g_memo;
|
||||
@ -542,14 +587,20 @@ char *gnc_hbci_memo_tognc (const HBCI_Transaction *h_trans)
|
||||
/** 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 HBCI_Account *h_acc)
|
||||
gnc_hbci_get_first_customer(const gnc_HBCI_Account *h_acc)
|
||||
{
|
||||
/* Get one customer. */
|
||||
const list_HBCI_Customer *custlist;
|
||||
|
||||
custlist = HBCI_Account_authorizedCustomers (h_acc);
|
||||
g_assert (custlist);
|
||||
return choose_one_customer(gnc_ui_get_toplevel (), custlist);
|
||||
const list_HBCI_User *userlist;
|
||||
const HBCI_Bank *bank;
|
||||
const HBCI_User *user;
|
||||
g_assert(h_acc);
|
||||
|
||||
bank = gnc_HBCI_Account_bank (h_acc);
|
||||
userlist = HBCI_Bank_users (bank);
|
||||
g_assert (userlist);
|
||||
user = choose_one_user(gnc_ui_get_toplevel (), userlist);
|
||||
g_assert (user);
|
||||
return choose_one_customer(gnc_ui_get_toplevel (), HBCI_User_customers (user));
|
||||
}
|
||||
|
||||
const char *bank_to_str (const HBCI_Bank *bank)
|
||||
@ -676,7 +727,7 @@ choose_one_customer (gncUIWidget parent, const list_HBCI_Customer *custlist)
|
||||
* is the name of the bank. %s is the bank
|
||||
* code. */
|
||||
g_strdup_printf (_("%s (%s) at bank %s (%s)"),
|
||||
HBCI_Customer_custName (customer),
|
||||
HBCI_Customer_name (customer),
|
||||
HBCI_Customer_custId (customer),
|
||||
bank_to_str (HBCI_User_bank(HBCI_Customer_user(customer))),
|
||||
HBCI_Bank_bankCode (HBCI_User_bank(HBCI_Customer_user(customer)))));
|
||||
@ -752,7 +803,7 @@ choose_one_user (gncUIWidget parent, const list_HBCI_User *userlist)
|
||||
radio_list = g_list_append
|
||||
(radio_list,
|
||||
g_strdup_printf (_("%s (%s) at bank %s (%s)"),
|
||||
HBCI_User_userName (user),
|
||||
HBCI_User_name (user),
|
||||
HBCI_User_userId (user),
|
||||
bank_to_str (HBCI_User_bank(user)),
|
||||
HBCI_Bank_bankCode (HBCI_User_bank(user))));
|
||||
|
@ -25,14 +25,17 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include <gnome.h>
|
||||
#include <openhbci/account.h>
|
||||
#include <openhbci/api.h>
|
||||
/*#include <openhbci2/account.h>*/
|
||||
#include <openhbci2/api.h>
|
||||
#include <openhbci2/transaction.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
|
||||
* configuration file filename. If the file doesn't exist and
|
||||
@ -49,7 +52,8 @@
|
||||
HBCI_API * gnc_hbci_api_new (const char *filename,
|
||||
gboolean allowNewFile,
|
||||
GtkWidget *parent,
|
||||
GNCInteractor **inter);
|
||||
GNCInteractor **inter,
|
||||
GList **list_accounts);
|
||||
|
||||
/** 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
|
||||
@ -61,7 +65,8 @@ HBCI_API * gnc_hbci_api_new (const char *filename,
|
||||
* May be NULL.
|
||||
*/
|
||||
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
|
||||
GNCInteractor **inter);
|
||||
GNCInteractor **inter,
|
||||
GList **list_accounts);
|
||||
|
||||
/** 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. */
|
||||
@ -77,14 +82,13 @@ HBCI_Error * gnc_hbci_api_save (const HBCI_API *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 HBCI_Account was found.
|
||||
* information. Returns NULL if no gnc_HBCI_Account was found.
|
||||
*
|
||||
* @param api The HBCI_API to get the HBCI_Account from.
|
||||
* @param gnc_acc The gnucash account to query for HBCI_Account reference data. */
|
||||
const HBCI_Account *
|
||||
* @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);
|
||||
|
||||
|
||||
/* 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. */
|
||||
@ -105,6 +109,7 @@ gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error,
|
||||
* should abort. */
|
||||
gboolean
|
||||
gnc_hbci_api_execute (GtkWidget *parent, HBCI_API *api,
|
||||
HBCI_Outbox *queue,
|
||||
HBCI_OutboxJob *job, GNCInteractor *inter);
|
||||
|
||||
|
||||
@ -122,7 +127,7 @@ char *gnc_hbci_memo_tognc (const HBCI_Transaction *h_trans);
|
||||
or NULL if none was found (and an error message is printed on
|
||||
stdout). */
|
||||
const HBCI_Customer *
|
||||
gnc_hbci_get_first_customer(const HBCI_Account *h_acc);
|
||||
gnc_hbci_get_first_customer(const gnc_HBCI_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
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <guile/gh.h>
|
||||
#include <glib.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
@ -65,16 +65,14 @@ libgncmod_hbci_LTX_gnc_module_init(int refcount)
|
||||
}
|
||||
|
||||
/* load the HBCI Scheme code */
|
||||
scm_c_eval_string("(load-from-path \"hbci/hbci.scm\")");
|
||||
gh_eval_str("(load-from-path \"hbci/hbci.scm\")");
|
||||
|
||||
scm_c_define_gsubr("gnc:hbci-initial-setup",
|
||||
0, 0, 0, scm_hbci_initial_druid);
|
||||
gh_new_procedure("gnc:hbci-initial-setup",
|
||||
scm_hbci_initial_druid, 0, 0, 0);
|
||||
|
||||
/* Add menu items with C callbacks */
|
||||
gnc_hbci_addmenus();
|
||||
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,7 @@
|
||||
#include "hbci-interaction.h"
|
||||
#include "hbci-interactionP.h"
|
||||
|
||||
#include <openhbci/interactorcb.h>
|
||||
#include <openhbci/progressmonitorcb.h>
|
||||
#include <openhbci2/interactorcb.h>
|
||||
#include "dialog-utils.h"
|
||||
#include "druid-utils.h"
|
||||
#include "gnc-ui-util.h"
|
||||
@ -39,11 +38,12 @@
|
||||
#include "dialog-pass.h"
|
||||
#include "gnc-hbci-utils.h"
|
||||
|
||||
#include <openhbci.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)
|
||||
{
|
||||
@ -61,11 +61,48 @@ GNCInteractor *gnc_hbci_api_interactors (HBCI_API *api, GtkWidget *parent)
|
||||
/* set HBCI_Interactor */
|
||||
HBCI_Hbci_setInteractor(HBCI_API_Hbci(api),
|
||||
gnc_hbci_new_interactor(data), TRUE);
|
||||
/* Set HBCI_Progressmonitor */
|
||||
HBCI_API_setMonitor(api, gnc_hbci_new_pmonitor(data), TRUE);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ************************************************************
|
||||
*/
|
||||
|
||||
|
||||
GtkWidget *GNCInteractor_parent(GNCInteractor *i)
|
||||
{
|
||||
g_assert(i);
|
||||
return i->parent;
|
||||
}
|
||||
|
||||
static void GNCInteractor_setRunning (GNCInteractor *data)
|
||||
{
|
||||
g_assert(data);
|
||||
data->state = RUNNING;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), TRUE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), FALSE);
|
||||
}
|
||||
static void GNCInteractor_setFinished (GNCInteractor *data)
|
||||
{
|
||||
g_assert(data);
|
||||
data->state = FINISHED;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), TRUE);
|
||||
if (gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (data->close_checkbutton)))
|
||||
GNCInteractor_hide (data);
|
||||
}
|
||||
static void GNCInteractor_setAborted (GNCInteractor *data)
|
||||
{
|
||||
g_assert(data);
|
||||
data->state = ABORTED;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), TRUE);
|
||||
data->keepAlive = FALSE;
|
||||
}
|
||||
|
||||
|
||||
gboolean GNCInteractor_aborted(const GNCInteractor *i)
|
||||
{
|
||||
g_assert(i);
|
||||
@ -170,13 +207,10 @@ static int msgInputPin(const HBCI_User *user,
|
||||
g_assert(data);
|
||||
|
||||
while (TRUE) {
|
||||
const char *username;
|
||||
username =
|
||||
(user ?
|
||||
(strlen (HBCI_User_userName (user)) > 0 ? HBCI_User_userName (user) :
|
||||
(HBCI_User_userId (user) ? HBCI_User_userId (user) :
|
||||
_("Unknown"))) :
|
||||
_("Unknown"));
|
||||
const char *username =
|
||||
(HBCI_User_name (user) ? HBCI_User_name (user) :
|
||||
(HBCI_User_userId (user) ? HBCI_User_userId (user) :
|
||||
_("Unknown")));
|
||||
g_assert (username);
|
||||
|
||||
if (newPin) {
|
||||
@ -259,7 +293,9 @@ static int msgInputPin(const HBCI_User *user,
|
||||
g_strdup_printf ( _("The PIN needs to be at least %d characters \n"
|
||||
"long. Do you want to try again?"),
|
||||
minsize);
|
||||
retval = gnc_verify_dialog (data->parent, TRUE, msg);
|
||||
retval = gnc_verify_dialog (GTK_WIDGET (data->parent),
|
||||
TRUE,
|
||||
msg);
|
||||
g_free (msg);
|
||||
if (!retval)
|
||||
break;
|
||||
@ -296,7 +332,7 @@ static int msgInsertMediumOrAbort(const HBCI_User *user,
|
||||
|
||||
if (user != NULL) {
|
||||
const char *username =
|
||||
(HBCI_User_userName (user) ? HBCI_User_userName (user) :
|
||||
(HBCI_User_name (user) ? HBCI_User_name (user) :
|
||||
(HBCI_User_userId (user) ? HBCI_User_userId (user) :
|
||||
_("Unknown")));
|
||||
b = HBCI_User_bank (user);
|
||||
@ -351,7 +387,9 @@ static int msgInsertMediumOrAbort(const HBCI_User *user,
|
||||
"the newly created user."));
|
||||
}
|
||||
|
||||
retval = gnc_ok_cancel_dialog (data->parent, GTK_RESPONSE_OK, "%s", msgstr);
|
||||
retval = gnc_ok_cancel_dialog (data->parent,
|
||||
GTK_RESPONSE_OK,
|
||||
"%s", msgstr);
|
||||
g_free (msgstr);
|
||||
|
||||
return (retval == GTK_RESPONSE_OK);
|
||||
@ -370,7 +408,7 @@ static int msgInsertCorrectMediumOrAbort(const HBCI_User *user,
|
||||
|
||||
if (user != NULL) {
|
||||
const char *username =
|
||||
(HBCI_User_userName (user) ? HBCI_User_userName (user) :
|
||||
(HBCI_User_name (user) ? HBCI_User_name (user) :
|
||||
(HBCI_User_userId (user) ? HBCI_User_userId (user) :
|
||||
_("Unknown")));
|
||||
b = HBCI_User_bank (user);
|
||||
@ -418,23 +456,23 @@ static int msgInsertCorrectMediumOrAbort(const HBCI_User *user,
|
||||
"the newly created user."));
|
||||
}
|
||||
|
||||
retval = gnc_ok_cancel_dialog (data->parent, GTK_RESPONSE_OK, "%s", msgstr);
|
||||
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)
|
||||
/*static void msgStateResponse(const char *msg, void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
g_assert(data);
|
||||
|
||||
add_log_text (data, msg);
|
||||
/*fprintf(stdout,"hbci-initial-druid-msgStateResponse: %s\n",msg);*/
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
}*/
|
||||
|
||||
static int keepAlive(void *user_data)
|
||||
{
|
||||
@ -490,7 +528,7 @@ msgStartInputPinViaKeypadCB(const HBCI_User *user, void *user_data)
|
||||
/* Create message string */
|
||||
if (user != NULL) {
|
||||
const char *username =
|
||||
(HBCI_User_userName (user) ? HBCI_User_userName (user) :
|
||||
(HBCI_User_name (user) ? HBCI_User_name (user) :
|
||||
(HBCI_User_userId (user) ? HBCI_User_userId (user) :
|
||||
_("Unknown")));
|
||||
bank = HBCI_User_bank (user);
|
||||
@ -524,6 +562,136 @@ msgStartInputPinViaKeypadCB(const HBCI_User *user, void *user_data)
|
||||
g_free (msgstr);
|
||||
}
|
||||
|
||||
/* ************************************************************
|
||||
*/
|
||||
|
||||
int debug_pmonitor = FALSE;
|
||||
|
||||
|
||||
/* old ProgressMonitor callbacks
|
||||
*/
|
||||
|
||||
static void actStarted (ActionProgressType type, void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
const char *msg = NULL;
|
||||
g_assert(data);
|
||||
switch (type) {
|
||||
/** Sending message. */
|
||||
case ACT_SENDINGMESSAGE:
|
||||
msg = _("Sending message");
|
||||
break;
|
||||
/** 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;
|
||||
default:
|
||||
msg = _("Unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
static void closeConnection(TransportType t, void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
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));
|
||||
}
|
||||
static void logMsg (const char *msg, void *user_data)
|
||||
{
|
||||
/* Note: this isn't used anyway. */
|
||||
GNCInteractor *data = user_data;
|
||||
g_assert(data);
|
||||
|
||||
printf("logMsg: Logging msg: %s\n", msg);
|
||||
add_log_text (data, msg);
|
||||
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
|
||||
void add_log_text (GNCInteractor *data, const char *msg)
|
||||
{
|
||||
int pos;
|
||||
g_assert(data);
|
||||
|
||||
pos = gtk_text_get_length (GTK_TEXT (data->log_text));
|
||||
gtk_editable_insert_text (GTK_EDITABLE (data->log_text),
|
||||
msg, strlen (msg),
|
||||
&pos);
|
||||
gtk_editable_insert_text (GTK_EDITABLE (data->log_text),
|
||||
"\n", 1,
|
||||
&pos);
|
||||
}
|
||||
|
||||
static void
|
||||
on_button_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
char *name;
|
||||
g_assert(data);
|
||||
|
||||
name = gtk_widget_get_name (GTK_WIDGET (button));
|
||||
if (strcmp (name, "abort_button") == 0) {
|
||||
GNCInteractor_setAborted(data);
|
||||
} else if (strcmp (name, "close_button") == 0) {
|
||||
if (data->state != RUNNING) {
|
||||
gtk_widget_hide_all (data->dialog);
|
||||
/*data->dont_hide = FALSE;*/
|
||||
/*GNCInteractor_hide (data);*/
|
||||
}
|
||||
} else {
|
||||
printf("on_button_clicked: Oops, unknown button: %s\n",
|
||||
name);
|
||||
}
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
@ -533,15 +701,53 @@ HBCI_Interactor *
|
||||
gnc_hbci_new_interactor(GNCInteractor *data)
|
||||
{
|
||||
HBCI_InteractorCB *inter;
|
||||
GtkWidget *dialog;
|
||||
GladeXML *xml;
|
||||
|
||||
inter = HBCI_InteractorCB_new2(&destr,
|
||||
/* Create the progress dialog window */
|
||||
xml = gnc_glade_xml_new ("hbci.glade", "HBCI_connection_dialog");
|
||||
|
||||
g_assert (dialog = glade_xml_get_widget (xml, "HBCI_connection_dialog"));
|
||||
data->dialog = dialog;
|
||||
g_assert (data->job_entry = glade_xml_get_widget (xml, "job_entry"));
|
||||
g_assert (data->action_entry = glade_xml_get_widget (xml, "action_entry"));
|
||||
g_assert (data->action_progress =
|
||||
glade_xml_get_widget (xml, "action_progress"));
|
||||
g_assert (data->log_text = glade_xml_get_widget (xml, "log_text"));
|
||||
g_assert (data->abort_button = glade_xml_get_widget (xml, "abort_button"));
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), FALSE);
|
||||
g_assert (data->close_button = glade_xml_get_widget (xml, "close_button"));
|
||||
g_assert (data->close_checkbutton =
|
||||
glade_xml_get_widget (xml, "close_checkbutton"));
|
||||
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON (data->close_checkbutton),
|
||||
gnc_lookup_boolean_option("__gui", "hbci_close_on_finish", TRUE));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (data->abort_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (on_button_clicked), data);
|
||||
gtk_signal_connect (GTK_OBJECT (data->close_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (on_button_clicked), data);
|
||||
|
||||
if (data->parent)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (data->parent));
|
||||
/*gtk_widget_set_parent (GTK_WIDGET (dialog), data->parent);*/
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (dialog));
|
||||
gtk_widget_hide_all (dialog);
|
||||
|
||||
|
||||
inter = HBCI_InteractorCB_new4(&destr,
|
||||
&msgInputPin,
|
||||
&msgInsertMediumOrAbort,
|
||||
&msgInsertCorrectMediumOrAbort,
|
||||
&msgStateResponse,
|
||||
&keepAlive,
|
||||
&msgStartInputPinViaKeypadCB,
|
||||
&msgEndInputPinViaKeypadCB,
|
||||
NULL,
|
||||
&closeConnection,
|
||||
&actStarted,
|
||||
&logMsg,
|
||||
data);
|
||||
|
||||
return HBCI_InteractorCB_Interactor(inter);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#ifndef HBCI_INTERACTION_H
|
||||
#define HBCI_INTERACTION_H
|
||||
|
||||
#include <openhbci/api.h>
|
||||
#include <openhbci2/api.h>
|
||||
#include <gnome.h>
|
||||
|
||||
typedef struct _inter_data GNCInteractor;
|
||||
@ -39,6 +39,7 @@ void GNCInteractor_delete(GNCInteractor *i);
|
||||
void GNCInteractor_erasePIN(GNCInteractor *i);
|
||||
void GNCInteractor_reparent (GNCInteractor *i, GtkWidget *new_parent);
|
||||
void GNCInteractor_set_cache_valid(GNCInteractor *i, gboolean value);
|
||||
GtkWidget *GNCInteractor_parent(GNCInteractor *i);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -24,8 +24,7 @@
|
||||
#ifndef HBCI_INTERACTIONP_H
|
||||
#define HBCI_INTERACTIONP_H
|
||||
|
||||
#include <openhbci/interactor.h>
|
||||
#include <openhbci/progressmonitor.h>
|
||||
#include <openhbci2/interactor.h>
|
||||
#include <gnome.h>
|
||||
|
||||
|
||||
@ -83,9 +82,6 @@ struct _inter_data
|
||||
|
||||
void delete_GNCInteractor (GNCInteractor *data);
|
||||
|
||||
HBCI_ProgressMonitor *
|
||||
gnc_hbci_new_pmonitor(GNCInteractor *data);
|
||||
|
||||
HBCI_Interactor *
|
||||
gnc_hbci_new_interactor(GNCInteractor *data);
|
||||
|
||||
|
@ -26,370 +26,12 @@
|
||||
#include "hbci-interaction.h"
|
||||
#include "hbci-interactionP.h"
|
||||
|
||||
#include <openhbci/interactorcb.h>
|
||||
#include <openhbci/progressmonitorcb.h>
|
||||
#include <openhbci.h>
|
||||
#include <openhbci2/interactorcb.h>
|
||||
#include <openhbci2.h>
|
||||
#include "dialog-utils.h"
|
||||
#include "druid-utils.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "global-options.h"
|
||||
|
||||
int debug_pmonitor = FALSE;
|
||||
|
||||
|
||||
static void GNCInteractor_setRunning (GNCInteractor *data)
|
||||
{
|
||||
g_assert(data);
|
||||
data->state = RUNNING;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), TRUE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), FALSE);
|
||||
}
|
||||
static void GNCInteractor_setFinished (GNCInteractor *data)
|
||||
{
|
||||
g_assert(data);
|
||||
data->state = FINISHED;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), TRUE);
|
||||
if (gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (data->close_checkbutton)))
|
||||
GNCInteractor_hide (data);
|
||||
}
|
||||
static void GNCInteractor_setAborted (GNCInteractor *data)
|
||||
{
|
||||
g_assert(data);
|
||||
data->state = ABORTED;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), TRUE);
|
||||
data->keepAlive = FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* now the callbacks
|
||||
*/
|
||||
static void transStarted (TransProgressType type,
|
||||
int jobs, void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
g_assert(data);
|
||||
|
||||
GNCInteractor_setRunning (data);
|
||||
|
||||
/*printf("Executing %d jobs.\n",jobs);*/
|
||||
data->jobs = jobs;
|
||||
data->current_job = 0;
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (data->job_entry), "");
|
||||
gtk_entry_set_text (GTK_ENTRY (data->action_entry), "");
|
||||
gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress), 0.0);
|
||||
if (debug_pmonitor)
|
||||
printf("transStarted-cb: current_job %d, jobs %d, current_act %d, actions %d.\n",
|
||||
data->current_job, data->jobs, data->current_act, data->actions);
|
||||
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
static void transFinished (void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
g_assert(data);
|
||||
GNCInteractor_setFinished (data);
|
||||
gtk_entry_set_text (GTK_ENTRY (data->job_entry), _("Finished"));
|
||||
gtk_entry_set_text (GTK_ENTRY (data->action_entry), _("Finished"));
|
||||
gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress), 1.0);
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
if (debug_pmonitor)
|
||||
printf("transFinished-cb: current_job %d, jobs %d, current_act %d, actions %d.\n",
|
||||
data->current_job, data->jobs, data->current_act, data->actions);
|
||||
}
|
||||
static void jobStarted(JobProgressType type, int actions, void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
const char *msg = NULL;
|
||||
g_assert(data);
|
||||
|
||||
switch(type){
|
||||
case JOB_OPENINGDIALOG:
|
||||
/* 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. */
|
||||
msg = _("Opening Dialog");
|
||||
break;
|
||||
case JOB_CLOSINGDIALOG:
|
||||
msg = _("Closing Dialog");
|
||||
break;
|
||||
/** Opening network connection. */
|
||||
case JOB_OPENINGNETWORK:
|
||||
msg = _("Opening Network Connection");
|
||||
break;
|
||||
/** Closing network connection. */
|
||||
case JOB_CLOSINGNETWORK:
|
||||
msg = _("Closing Network Connection");
|
||||
break;
|
||||
/** Get balance */
|
||||
case JOB_GET_BALANCE:
|
||||
/* Translate those with keeping the leading "Job:", but of course
|
||||
using a translation for "Job". */
|
||||
msg = _("Job: Get Balance");
|
||||
break;
|
||||
/** Get transaction statement */
|
||||
case JOB_GET_TRANS:
|
||||
msg = _("Job: Get Transactions");
|
||||
break;
|
||||
/** Transfer money */
|
||||
case JOB_NEW_TRANSFER:
|
||||
msg = _("Job: New Transfer");
|
||||
break;
|
||||
/** Debit note */
|
||||
case JOB_DEBIT_NOTE:
|
||||
msg = _("Job: Debit Note");
|
||||
break;
|
||||
/** Get standing orders */
|
||||
case JOB_GET_STO:
|
||||
msg = _("Job: Get Standing Orders");
|
||||
break;
|
||||
/** Create a new standing order */
|
||||
case JOB_NEW_STO:
|
||||
msg = _("Job: New Standing Order");
|
||||
break;
|
||||
/** Delete a standing order */
|
||||
case JOB_DELETE_STO:
|
||||
msg = _("Job: Delete Standing Order");
|
||||
break;
|
||||
/** Get account list */
|
||||
case JOB_GET_ACCOUNTS:
|
||||
msg = _("Job: Retrieve Account List");
|
||||
break;
|
||||
/** Get SystemId */
|
||||
case JOB_GET_SYSTEMID:
|
||||
msg = _("Job: Get System ID");
|
||||
break;
|
||||
/** Get keys */
|
||||
case JOB_GET_KEYS:
|
||||
msg = _("Job: Get Keys");
|
||||
break;
|
||||
/** Send keys */
|
||||
case JOB_SEND_KEYS:
|
||||
msg = _("Job: Send Keys");
|
||||
break;
|
||||
/** Disable keys */
|
||||
case JOB_DISABLE_KEYS:
|
||||
msg = _("Job: Disable Keys");
|
||||
break;
|
||||
/** Change keys */
|
||||
case JOB_CHANGE_KEYS:
|
||||
msg = _("Job: Change Keys");
|
||||
break;
|
||||
/** Change keys */
|
||||
case JOB_GET_STATUS:
|
||||
msg = _("Job: Get Status Reports");
|
||||
break;
|
||||
#if 0
|
||||
default:
|
||||
msg = _("Unknown");
|
||||
#endif
|
||||
}
|
||||
g_assert(msg);
|
||||
|
||||
/*printf("Jobstart (w/ %d actions): %s\n",actions, msg);*/
|
||||
data->actions = actions;
|
||||
data->current_act = 0;
|
||||
gtk_entry_set_text (GTK_ENTRY (data->job_entry), msg);
|
||||
gtk_entry_set_text (GTK_ENTRY (data->action_entry), "");
|
||||
gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress), 0.0);
|
||||
if (debug_pmonitor)
|
||||
printf("jobStarted-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);
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
static void jobFinished (void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
g_assert(data);
|
||||
data->current_job++;
|
||||
gtk_entry_set_text (GTK_ENTRY (data->job_entry), _("Done"));
|
||||
/*gtk_entry_set_text (GTK_ENTRY (data->action_entry), _("Done"));
|
||||
GNCInteractor_setFinished (data);
|
||||
gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress), 1.0);*/
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
if (debug_pmonitor)
|
||||
printf("jobFinished-cb: current_job %d, jobs %d, current_act %d, actions %d.\n",
|
||||
data->current_job, data->jobs, data->current_act, data->actions);
|
||||
}
|
||||
|
||||
static void actStarted (ActionProgressType type, void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
const char *msg = NULL;
|
||||
g_assert(data);
|
||||
switch (type) {
|
||||
/** Sending message. */
|
||||
case ACT_SENDINGMESSAGE:
|
||||
msg = _("Sending message");
|
||||
break;
|
||||
/** Waiting for response. */
|
||||
case ACT_WAITRESPONSE:
|
||||
msg = _("Waiting for response");
|
||||
break;
|
||||
/** Creating HBCI job. Number of Job will follow in string argument. */
|
||||
case ACT_CREATEHBCIJOB:
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
static void actFinished (void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
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),
|
||||
(data->current_act < data->actions) ?
|
||||
((float) data->current_act /
|
||||
(float) data->actions) :
|
||||
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);
|
||||
}
|
||||
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
static void logMsg (const char *msg, void *user_data)
|
||||
{
|
||||
/* Note: this isn't used anyway. */
|
||||
GNCInteractor *data = user_data;
|
||||
g_assert(data);
|
||||
|
||||
printf("logMsg: Logging msg: %s\n", msg);
|
||||
add_log_text (data, msg);
|
||||
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
|
||||
void add_log_text (GNCInteractor *data, const char *msg)
|
||||
{
|
||||
int pos;
|
||||
g_assert(data);
|
||||
|
||||
pos = gtk_text_get_length (GTK_TEXT (data->log_text));
|
||||
gtk_editable_insert_text (GTK_EDITABLE (data->log_text),
|
||||
msg, strlen (msg),
|
||||
&pos);
|
||||
gtk_editable_insert_text (GTK_EDITABLE (data->log_text),
|
||||
"\n", 1,
|
||||
&pos);
|
||||
}
|
||||
|
||||
static void destr(void *user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
|
||||
GNCInteractor_delete (data);
|
||||
}
|
||||
static void
|
||||
on_button_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCInteractor *data = user_data;
|
||||
char *name;
|
||||
g_assert(data);
|
||||
|
||||
name = gtk_widget_get_name (GTK_WIDGET (button));
|
||||
if (strcmp (name, "abort_button") == 0) {
|
||||
GNCInteractor_setAborted(data);
|
||||
} else if (strcmp (name, "close_button") == 0) {
|
||||
if (data->state != RUNNING) {
|
||||
gtk_widget_hide_all (data->dialog);
|
||||
/*data->dont_hide = FALSE;*/
|
||||
/*GNCInteractor_hide (data);*/
|
||||
}
|
||||
} else {
|
||||
printf("on_button_clicked: Oops, unknown button: %s\n",
|
||||
name);
|
||||
}
|
||||
/* Let the widgets be redrawn */
|
||||
while (g_main_iteration (FALSE));
|
||||
}
|
||||
|
||||
HBCI_ProgressMonitor *
|
||||
gnc_hbci_new_pmonitor(GNCInteractor *data)
|
||||
{
|
||||
HBCI_ProgressMonitorCB *pmon;
|
||||
GtkWidget *dialog;
|
||||
GladeXML *xml;
|
||||
|
||||
xml = gnc_glade_xml_new ("hbci.glade", "HBCI_connection_dialog");
|
||||
|
||||
g_assert (dialog = glade_xml_get_widget (xml, "HBCI_connection_dialog"));
|
||||
data->dialog = dialog;
|
||||
g_assert (data->job_entry = glade_xml_get_widget (xml, "job_entry"));
|
||||
g_assert (data->action_entry = glade_xml_get_widget (xml, "action_entry"));
|
||||
g_assert (data->action_progress =
|
||||
glade_xml_get_widget (xml, "action_progress"));
|
||||
g_assert (data->log_text = glade_xml_get_widget (xml, "log_text"));
|
||||
g_assert (data->abort_button = glade_xml_get_widget (xml, "abort_button"));
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), FALSE);
|
||||
g_assert (data->close_button = glade_xml_get_widget (xml, "close_button"));
|
||||
g_assert (data->close_checkbutton =
|
||||
glade_xml_get_widget (xml, "close_checkbutton"));
|
||||
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON (data->close_checkbutton),
|
||||
gnc_lookup_boolean_option("__gui", "hbci_close_on_finish", TRUE));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (data->abort_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (on_button_clicked), data);
|
||||
gtk_signal_connect (GTK_OBJECT (data->close_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (on_button_clicked), data);
|
||||
|
||||
if (data->parent)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (data->parent));
|
||||
/*gtk_widget_set_parent (GTK_WIDGET (dialog), data->parent);*/
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (dialog));
|
||||
gtk_widget_hide_all (dialog);
|
||||
|
||||
pmon = HBCI_ProgressMonitorCB_new(&destr,
|
||||
&transStarted, &transFinished,
|
||||
&jobStarted, &jobFinished,
|
||||
&actStarted, &actFinished,
|
||||
&logMsg,
|
||||
data);
|
||||
|
||||
return HBCI_ProgressMonitorCB_ProgressMonitor(pmon);
|
||||
}
|
||||
/* currently empty */
|
||||
|
Loading…
Reference in New Issue
Block a user