mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2002-10-26 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/gnc-hbci-kvp.h, src/import-export/hbci/gnc-hbci-gettrans.c: Remember the user's date of last transaction retrieval. REQUIRES updating to current OPENHBCI CVS. * src/import-export/hbci/gnc-hbci-utils.c: Cache the created HBCI_API for subsequent calls. Will also cache the user's password. Also, make more meaningful error handling. * src/import-export/hbci/dialog-daterange.[hc]: Add a dialog asking for the date range of transactions to retrieve. * src/engine/date.h: Add timespecToTime_t function. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7385 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f5e9c06389
commit
e65faf11f1
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2002-10-26 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/hbci/gnc-hbci-kvp.h,
|
||||
src/import-export/hbci/gnc-hbci-gettrans.c: Remember the user's
|
||||
date of last transaction retrieval. REQUIRES updating to current
|
||||
OPENHBCI CVS.
|
||||
|
||||
* src/import-export/hbci/gnc-hbci-utils.c: Cache the created
|
||||
HBCI_API for subsequent calls. Will also cache the user's
|
||||
password. Also, make more meaningful error handling.
|
||||
|
||||
* src/import-export/hbci/dialog-daterange.[hc]: Add a dialog
|
||||
asking for the date range of transactions to retrieve.
|
||||
|
||||
* src/engine/date.h: Add timespecToTime_t function.
|
||||
|
||||
2002-10-25 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome/window-register.c: Use a better function for making
|
||||
|
@ -951,5 +951,11 @@ timespecFromTime_t( Timespec *ts, time_t t )
|
||||
ts->tv_nsec = 0;
|
||||
}
|
||||
|
||||
time_t
|
||||
timespecToTime_t (Timespec ts)
|
||||
{
|
||||
return ts.tv_sec;
|
||||
}
|
||||
|
||||
/********************** END OF FILE *********************************\
|
||||
\********************************************************************/
|
||||
|
@ -150,6 +150,12 @@ const char * gnc_print_date(Timespec ts);
|
||||
**/
|
||||
void timespecFromTime_t( Timespec *ts, time_t t );
|
||||
|
||||
/**
|
||||
* Turns a Timespec into a time_t
|
||||
*/
|
||||
time_t timespecToTime_t (Timespec ts);
|
||||
|
||||
|
||||
/**
|
||||
* scanDate
|
||||
* Convert a string into day / month / year integers according to
|
||||
|
@ -7,6 +7,7 @@ libgncmod_hbci_la_SOURCES = \
|
||||
druid-hbci-utils.c \
|
||||
dialog-pass.c \
|
||||
dialog-hbcitrans.c \
|
||||
dialog-daterange.c \
|
||||
gnc-hbci-kvp.c \
|
||||
gnc-hbci-utils.c \
|
||||
gnc-hbci-cb.c \
|
||||
|
149
src/import-export/hbci/dialog-daterange.c
Normal file
149
src/import-export/hbci/dialog-daterange.c
Normal file
@ -0,0 +1,149 @@
|
||||
/********************************************************************\
|
||||
* dialog-daterange.c -- dialog for date range entry *
|
||||
* Copyright (C) 2002 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 <gnome.h>
|
||||
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-date-edit.h"
|
||||
#include "dialog-daterange.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *enter_from_button;
|
||||
GtkWidget *enter_to_button;
|
||||
GtkWidget *from_dateedit;
|
||||
GtkWidget *to_dateedit;
|
||||
} DaterangeInfo;
|
||||
|
||||
void on_button_toggled (GtkToggleButton *button, gpointer user_data);
|
||||
|
||||
|
||||
gboolean
|
||||
gnc_hbci_enter_daterange (GtkWidget *parent,
|
||||
const char *heading,
|
||||
Timespec *from_date,
|
||||
gboolean *last_retv_date,
|
||||
gboolean *first_possible_date,
|
||||
Timespec *to_date,
|
||||
gboolean *to_now)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GladeXML *xml;
|
||||
gint result;
|
||||
DaterangeInfo info;
|
||||
|
||||
GtkWidget *heading_label;
|
||||
GtkWidget *last_retrieval_button;
|
||||
GtkWidget *first_button;
|
||||
GtkWidget *now_button;
|
||||
|
||||
xml = gnc_glade_xml_new ("hbci.glade", "HBCI_daterange_dialog");
|
||||
|
||||
g_assert
|
||||
(dialog = glade_xml_get_widget (xml, "HBCI_daterange_dialog"));
|
||||
|
||||
if (parent)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (parent));
|
||||
|
||||
g_assert
|
||||
(heading_label = glade_xml_get_widget (xml, "heading_label"));
|
||||
g_assert
|
||||
(last_retrieval_button = glade_xml_get_widget (xml, "last_retrieval_button"));
|
||||
g_assert
|
||||
(first_button = glade_xml_get_widget (xml, "first_button"));
|
||||
g_assert
|
||||
(info.enter_from_button = glade_xml_get_widget (xml, "enter_from_button"));
|
||||
g_assert
|
||||
(info.enter_to_button = glade_xml_get_widget (xml, "enter_to_button"));
|
||||
g_assert
|
||||
(now_button = glade_xml_get_widget (xml, "now_button"));
|
||||
|
||||
info.from_dateedit = gnc_date_edit_new_ts (*from_date, FALSE, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (glade_xml_get_widget
|
||||
(xml, "enter_from_box")),
|
||||
info.from_dateedit);
|
||||
|
||||
info.to_dateedit = gnc_date_edit_new_ts (*to_date, FALSE, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (glade_xml_get_widget
|
||||
(xml, "enter_to_box")),
|
||||
info.to_dateedit);
|
||||
|
||||
if (*last_retv_date == FALSE) {
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (first_button), TRUE);
|
||||
gtk_widget_set_sensitive (last_retrieval_button, FALSE);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (info.from_dateedit, FALSE);
|
||||
gtk_widget_set_sensitive (info.to_dateedit, FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (info.enter_from_button), "toggled",
|
||||
GTK_SIGNAL_FUNC (on_button_toggled), &info);
|
||||
gtk_signal_connect (GTK_OBJECT (info.enter_to_button), "toggled",
|
||||
GTK_SIGNAL_FUNC (on_button_toggled), &info);
|
||||
|
||||
gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
|
||||
|
||||
if (heading)
|
||||
gtk_label_set_text (GTK_LABEL (heading_label), heading);
|
||||
|
||||
gtk_widget_grab_focus (glade_xml_get_widget (xml, "ok_button"));
|
||||
|
||||
/* Hide on close instead of destroy since we still need the values
|
||||
from the boxes. */
|
||||
gnome_dialog_close_hides (GNOME_DIALOG (dialog), TRUE);
|
||||
gtk_widget_show_all (GTK_WIDGET (dialog));
|
||||
|
||||
result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
*from_date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (info.from_dateedit));
|
||||
*last_retv_date = gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (last_retrieval_button));
|
||||
*first_possible_date = gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (first_button));
|
||||
*to_date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (info.to_dateedit));
|
||||
*to_now = gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (now_button));
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void on_button_toggled (GtkToggleButton *button, gpointer user_data)
|
||||
{
|
||||
DaterangeInfo *info = user_data;
|
||||
g_assert (info);
|
||||
|
||||
gtk_widget_set_sensitive (info->from_dateedit,
|
||||
gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (info->enter_from_button)));
|
||||
gtk_widget_set_sensitive (info->to_dateedit,
|
||||
gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (info->enter_to_button)));
|
||||
}
|
40
src/import-export/hbci/dialog-daterange.h
Normal file
40
src/import-export/hbci/dialog-daterange.h
Normal file
@ -0,0 +1,40 @@
|
||||
/********************************************************************\
|
||||
* dialog-daterange.h -- dialog for date range entry *
|
||||
* Copyright (C) 2002 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 DIALOG_DATERANGE_H
|
||||
#define DIALOG_DATERANGE_H
|
||||
|
||||
#include <gnome.h>
|
||||
#include "date.h"
|
||||
|
||||
gboolean
|
||||
gnc_hbci_enter_daterange (GtkWidget *parent,
|
||||
const char *heading,
|
||||
Timespec *from_date,
|
||||
gboolean *last_retv_date,
|
||||
gboolean *first_possible_date,
|
||||
Timespec *to_date,
|
||||
gboolean *to_now);
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -151,7 +151,7 @@ reset_initial_info (HBCIInitialInfo *info)
|
||||
if (info == NULL) return;
|
||||
|
||||
if (info->api != NULL)
|
||||
HBCI_API_delete (info->api);
|
||||
gnc_hbci_api_delete (info->api);
|
||||
info->api = NULL;
|
||||
info->newcustomer = NULL;
|
||||
info->newbank = NULL;
|
||||
@ -907,7 +907,7 @@ on_accountinfo_next (GnomeDruidPage *gnomedruidpage,
|
||||
if (info->interactor)
|
||||
GNCInteractor_show (info->interactor);
|
||||
|
||||
HBCI_Hbci_setDebugLevel(0);
|
||||
HBCI_Hbci_setDebugLevel(3);
|
||||
err = HBCI_API_executeQueue (info->api, TRUE);
|
||||
g_assert (err);
|
||||
if (!HBCI_Error_isOk(err)) {
|
||||
|
@ -2646,4 +2646,265 @@ Press 'Finish' now.</text>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GnomeDialog</class>
|
||||
<name>HBCI_daterange_dialog</name>
|
||||
<title>Get Transactions Online</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>False</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>GnomeDialog:vbox</child_name>
|
||||
<name>dialog-vbox4</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>8</spacing>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<child_name>GnomeDialog:action_area</child_name>
|
||||
<name>dialog-action_area4</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>8</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>ok_button</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>cancel_button</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox152</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>heading_label</name>
|
||||
<label>Date range of transactions to retrieve:</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>frame70</name>
|
||||
<label>From</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox153</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>last_retrieval_button</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Last retrieval date</label>
|
||||
<active>True</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>fromdate</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox115</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>enter_from_button</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Enter date:</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>fromdate</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>enter_from_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>first_button</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>First possible date</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>fromdate</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>frame71</name>
|
||||
<label>To</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox154</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>now_button</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Now</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>todate</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox116</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>enter_to_button</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Enter date:</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>todate</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>enter_to_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
</GTK-Interface>
|
||||
|
@ -103,8 +103,10 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
GNCInteractor_show (interactor);
|
||||
|
||||
HBCI_Hbci_setDebugLevel(0);
|
||||
err = HBCI_API_executeQueue (api, TRUE);
|
||||
g_assert (err);
|
||||
do {
|
||||
err = HBCI_API_executeQueue (api, TRUE);
|
||||
g_assert (err);
|
||||
} while (gnc_hbci_error_retry (parent, err));
|
||||
if (!HBCI_Error_isOk(err)) {
|
||||
char *errstr = g_strdup_printf("gnc_hbci_getbalance: Error at executeQueue: %s",
|
||||
HBCI_Error_message (err));
|
||||
|
@ -34,14 +34,19 @@
|
||||
#include "hbci-interaction.h"
|
||||
#include "gnc-hbci-utils.h"
|
||||
#include "dialog-hbcitrans.h"
|
||||
#include "gnc-hbci-kvp.h"
|
||||
#include "dialog-daterange.h"
|
||||
|
||||
|
||||
static void *trans_list_cb (const HBCI_Transaction *trans, void *user_data);
|
||||
|
||||
struct trans_list_data
|
||||
{
|
||||
Account *gnc_acc;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void
|
||||
gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
{
|
||||
@ -99,13 +104,53 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
HBCI_OutboxJobGetTransactions *trans_job;
|
||||
HBCI_OutboxJob *job;
|
||||
HBCI_Error *err;
|
||||
HBCI_Date *blank_date = HBCI_Date_new_blank();
|
||||
|
||||
Timespec last_timespec, until_timespec;
|
||||
time_t now = time(NULL), time_convert;
|
||||
struct tm tm;
|
||||
HBCI_Date *from_date, *to_date;
|
||||
gboolean use_last_date = TRUE,
|
||||
use_earliest_date = TRUE, use_until_now = TRUE;
|
||||
|
||||
/* Get time of last retrieval */
|
||||
last_timespec = gnc_hbci_get_account_trans_retrieval (gnc_acc);
|
||||
if (last_timespec.tv_sec == 0) {
|
||||
use_last_date = FALSE;
|
||||
timespecFromTime_t (&last_timespec, now);
|
||||
}
|
||||
timespecFromTime_t (&until_timespec, now);
|
||||
|
||||
/* Let the user choose the date range of retrieval */
|
||||
if (!gnc_hbci_enter_daterange (parent, NULL,
|
||||
&last_timespec,
|
||||
&use_last_date, &use_earliest_date,
|
||||
&until_timespec, &use_until_now))
|
||||
return;
|
||||
|
||||
/*printf("Retrieving transactions from date %s to date %s. \n",
|
||||
ctime(&()))*/
|
||||
|
||||
/* Now calculate from date */
|
||||
if (use_earliest_date)
|
||||
from_date = HBCI_Date_new_blank();
|
||||
else {
|
||||
if (use_last_date)
|
||||
last_timespec = gnc_hbci_get_account_trans_retrieval (gnc_acc);
|
||||
time_convert = timespecToTime_t(last_timespec);
|
||||
from_date = HBCI_Date_new (localtime_r (&time_convert, &tm));
|
||||
}
|
||||
|
||||
/* Now calculate to date */
|
||||
if (use_until_now)
|
||||
timespecFromTime_t (&until_timespec, now);
|
||||
time_convert = timespecToTime_t (until_timespec);
|
||||
to_date = HBCI_Date_new (localtime_r (&time_convert, &tm));
|
||||
|
||||
/* Create OutboxJob */
|
||||
trans_job =
|
||||
HBCI_OutboxJobGetTransactions_new (customer,
|
||||
(HBCI_Account *)h_acc,
|
||||
blank_date,
|
||||
blank_date);
|
||||
from_date,
|
||||
to_date);
|
||||
job = HBCI_OutboxJobGetTransactions_OutboxJob (trans_job);
|
||||
g_assert (job);
|
||||
HBCI_API_addJob (api, job);
|
||||
@ -114,8 +159,11 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
GNCInteractor_show (interactor);
|
||||
|
||||
HBCI_Hbci_setDebugLevel(0);
|
||||
err = HBCI_API_executeQueue (api, TRUE);
|
||||
g_assert (err);
|
||||
do {
|
||||
err = HBCI_API_executeQueue (api, TRUE);
|
||||
g_assert (err);
|
||||
} while (gnc_hbci_error_retry (parent, err));
|
||||
|
||||
if (!HBCI_Error_isOk(err)) {
|
||||
char *errstr = g_strdup_printf("gnc_hbci_gettrans: Error at executeQueue: %s",
|
||||
HBCI_Error_message (err));
|
||||
@ -128,19 +176,28 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
gnc_hbci_debug_outboxjob (job);
|
||||
return;
|
||||
}
|
||||
/*HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_DONE);*/
|
||||
HBCI_Error_delete (err);
|
||||
HBCI_Date_delete (blank_date);
|
||||
|
||||
HBCI_Date_delete (from_date);
|
||||
HBCI_Date_delete (to_date);
|
||||
|
||||
/* Store the date of this retrieval */
|
||||
gnc_hbci_set_account_trans_retrieval (gnc_acc, until_timespec);
|
||||
|
||||
{
|
||||
/* Now add the retrieved transactions to the gnucash account. */
|
||||
const list_HBCI_Transaction *trans_list;
|
||||
struct trans_list_data data;
|
||||
|
||||
data.gnc_acc = gnc_acc;
|
||||
|
||||
trans_list = HBCI_OutboxJobGetTransactions_transactions (trans_job);
|
||||
printf("Got %d transactions.\n",
|
||||
list_HBCI_Transaction_size(trans_list));
|
||||
list_HBCI_Transaction_foreach (trans_list, trans_list_cb, &data);
|
||||
}
|
||||
|
||||
/* Clean up behind ourself. */
|
||||
/*HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_DONE);*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,7 +306,3 @@ static void *trans_list_cb (const HBCI_Transaction *h_trans,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define HBCI_BANK_CODE "bank-code"
|
||||
#define HBCI_COUNTRY_CODE "country-code"
|
||||
#define HBCI_CONFIGFILE "config-filename"
|
||||
#define HBCI_TRANS_RETRIEVAL "trans-retrieval"
|
||||
|
||||
/* Account */
|
||||
char *gnc_hbci_get_account_accountid (Account *a)
|
||||
@ -47,6 +48,12 @@ gint gnc_hbci_get_account_countrycode (Account *a)
|
||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_COUNTRY_CODE);
|
||||
return kvp_value_get_gint64 (value);
|
||||
}
|
||||
Timespec gnc_hbci_get_account_trans_retrieval (Account *a)
|
||||
{
|
||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TRANS_RETRIEVAL);
|
||||
return kvp_value_get_timespec (value);
|
||||
}
|
||||
void gnc_hbci_set_account_accountid (Account *a, const char *id)
|
||||
{
|
||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
||||
@ -71,6 +78,15 @@ void gnc_hbci_set_account_countrycode (Account *a, gint code)
|
||||
kvp_frame_set_slot_nc (frame, HBCI_COUNTRY_CODE, value);
|
||||
xaccAccountCommitEdit (a);
|
||||
}
|
||||
void gnc_hbci_set_account_trans_retrieval (Account *a, Timespec time)
|
||||
{
|
||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
||||
kvp_value *value = kvp_value_new_timespec (time);
|
||||
xaccAccountBeginEdit (a);
|
||||
kvp_frame_set_slot_nc (frame, HBCI_TRANS_RETRIEVAL, value);
|
||||
xaccAccountCommitEdit (a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* GNCBook */
|
||||
|
@ -53,6 +53,13 @@ gint gnc_hbci_get_account_countrycode (Account *a);
|
||||
* will be marked as "dirty". */
|
||||
void gnc_hbci_set_account_countrycode (Account *a, gint code);
|
||||
|
||||
/** Returns the time of last online transaction retrieval */
|
||||
Timespec gnc_hbci_get_account_trans_retrieval (Account *a);
|
||||
/** Set the time of last online transaction retrieval. The account
|
||||
* will be marked as "dirty". */
|
||||
void gnc_hbci_set_account_trans_retrieval (Account *a, Timespec time);
|
||||
|
||||
|
||||
/* GNCBook */
|
||||
|
||||
/** Returns a non-copied pointer to the configfile string in the
|
||||
|
@ -68,15 +68,32 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
return api;
|
||||
};
|
||||
|
||||
static HBCI_API *gnc_hbci_api = NULL;
|
||||
static GNCInteractor *gnc_hbci_inter = NULL;
|
||||
|
||||
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
|
||||
GNCInteractor **inter)
|
||||
{
|
||||
return gnc_hbci_api_new
|
||||
(gnc_hbci_get_book_configfile (gnc_get_current_book ()),
|
||||
FALSE, parent, inter);
|
||||
if (gnc_hbci_api == NULL) {
|
||||
gnc_hbci_api = gnc_hbci_api_new
|
||||
(gnc_hbci_get_book_configfile (gnc_get_current_book ()),
|
||||
FALSE, parent, inter);
|
||||
gnc_hbci_inter = *inter;
|
||||
}
|
||||
*inter = gnc_hbci_inter;
|
||||
return gnc_hbci_api;
|
||||
};
|
||||
|
||||
void gnc_hbci_api_delete (HBCI_API *api)
|
||||
{
|
||||
if (api == gnc_hbci_api) {
|
||||
gnc_hbci_api = NULL;
|
||||
gnc_hbci_inter = NULL;
|
||||
}
|
||||
HBCI_API_delete (api);
|
||||
}
|
||||
|
||||
|
||||
HBCI_Error * gnc_hbci_api_save (const HBCI_API *api)
|
||||
{
|
||||
const char *file = gnc_hbci_get_book_configfile (gnc_get_current_book ());
|
||||
@ -184,3 +201,34 @@ gnc_hbci_debug_outboxjob (HBCI_OutboxJob *job)
|
||||
printf("Probable cause of error was: code %d, msg: %s\n", cause, msg);
|
||||
list_int_delete (list);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error)
|
||||
{
|
||||
int code = HBCI_Error_code (error);
|
||||
|
||||
switch (code) {
|
||||
case HBCI_ERROR_CODE_PIN_WRONG:
|
||||
return gnc_verify_dialog_parented (parent,
|
||||
TRUE,
|
||||
_("The PIN you entered was wrong.\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:
|
||||
return gnc_verify_dialog_parented (parent,
|
||||
TRUE,
|
||||
_("The PIN you entered was too short.\n"
|
||||
"Do you want to try again?"));
|
||||
case HBCI_ERROR_CODE_FILE_NOT_FOUND:
|
||||
printf("gnc_hbci_error_feedback: File not found error.\n");
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ HBCI_API * gnc_hbci_api_new (const char *filename,
|
||||
GNCInteractor **inter);
|
||||
|
||||
/** Same as above, but takes the filename already from the current
|
||||
* book's kvp frame. Returns NULL if the file from the book's kvp
|
||||
* frame doesn't exist. Returns NULL also when there was an error upon
|
||||
* opening that file.
|
||||
* book's kvp frame AND caches a pointer to the api. Returns NULL if
|
||||
* the file from the book's kvp frame doesn't exist. Returns NULL also
|
||||
* when there was an error upon opening that file.
|
||||
*
|
||||
* @param parent When displaying dialogs, use this GtkWidget as parent.
|
||||
* @param inter Reference to a GNCInteractor-pointer in order to use this later.
|
||||
@ -61,6 +61,10 @@ HBCI_API * gnc_hbci_api_new (const char *filename,
|
||||
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
|
||||
GNCInteractor **inter);
|
||||
|
||||
/** Delete the given HBCI_API. If this is also the one that was cached
|
||||
by gnc_hbci_api_new_currentbook, then that reference is deleted, too. */
|
||||
void gnc_hbci_api_delete (HBCI_API *api);
|
||||
|
||||
|
||||
/** Save this API to the config file given in the current book. Return
|
||||
* an error if one occurred, or if no filename was found in the
|
||||
@ -83,6 +87,11 @@ gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc);
|
||||
void
|
||||
gnc_hbci_debug_outboxjob (HBCI_OutboxJob *job);
|
||||
|
||||
|
||||
/* Check HBCI_Error on whether some feedback should be given to the
|
||||
* user. Returns true if the HBCI action should be tried again; on the
|
||||
* other hand, returns false if the user can't do anything about this
|
||||
* error right now. */
|
||||
gboolean
|
||||
gnc_hbci_error_retry (GtkWidget *parent, HBCI_Error *error);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user