[Gnucash-changes] More HBCI work.
Christian Stimming
cstim at cvs.gnucash.org
Sat Sep 18 03:59:18 EDT 2004
Log Message:
-----------
More HBCI work.
Modified Files:
--------------
gnucash/src/import-export/hbci:
dialog-hbcitrans.c
dialog-pass.c
dialog-pass.h
gnc-hbci-getbalance.c
gnc-hbci-gettrans.c
gnc-hbci-transfer.c
hbci-interaction.c
Revision Data
-------------
Index: dialog-pass.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/dialog-pass.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lsrc/import-export/hbci/dialog-pass.h -Lsrc/import-export/hbci/dialog-pass.h -u -r1.2 -r1.3
--- src/import-export/hbci/dialog-pass.h
+++ src/import-export/hbci/dialog-pass.h
@@ -27,11 +27,13 @@
gboolean
gnc_hbci_get_password (GtkWidget *parent,
+ const char *windowtitle,
const char *heading,
const char *initial_password,
char **password);
gboolean
gnc_hbci_get_initial_password (GtkWidget *parent,
+ const char *windowtitle,
const char *heading,
char **password);
Index: hbci-interaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interaction.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lsrc/import-export/hbci/hbci-interaction.c -Lsrc/import-export/hbci/hbci-interaction.c -u -r1.39 -r1.40
--- src/import-export/hbci/hbci-interaction.c
+++ src/import-export/hbci/hbci-interaction.c
@@ -38,6 +38,11 @@
#include "dialog-pass.h"
#include "gnc-hbci-utils.h"
+#include <gwenhywfar/bio_buffer.h>
+#include <gwenhywfar/xml.h>
+
+#include <libxml/encoding.h>
+
#define PREF_TAB_ONLINE_BANKING N_("Online Banking & Importing")
@@ -192,25 +197,84 @@
}
}
+/* ************************************************************
+ */
+
+/* This function extracts the normal text part out of the
+ combi-strings that are passed from aqbanking. */
+static int gnc__extractText(const char *text, GWEN_BUFFER *tbuf) {
+ GWEN_BUFFEREDIO *bio;
+ GWEN_XMLNODE *xmlNode;
+ GWEN_BUFFER *buf;
+ int rv;
+
+ buf=GWEN_Buffer_new(0, 256, 0, 1);
+ GWEN_Buffer_AppendString(buf, text);
+ GWEN_Buffer_Rewind(buf);
+ bio=GWEN_BufferedIO_Buffer2_new(buf, 1);
+ GWEN_BufferedIO_SetReadBuffer(bio, 0, 256);
+ xmlNode=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "html");
+ rv=GWEN_XML_Parse(xmlNode, bio,
+ GWEN_XML_FLAGS_DEFAULT |
+ GWEN_XML_FLAGS_HANDLE_OPEN_HTMLTAGS |
+ GWEN_XML_FLAGS_NO_CONDENSE |
+ GWEN_XML_FLAGS_KEEP_CNTRL);
+ GWEN_BufferedIO_Close(bio);
+ GWEN_BufferedIO_free(bio);
+ if (rv) {
+ /* DBG_NOTICE(0, "here"); */
+ GWEN_XMLNode_free(xmlNode);
+ return -1;
+ }
+ else {
+ GWEN_XMLNODE *nn;
+
+ nn=GWEN_XMLNode_GetFirstData(xmlNode);
+ if (nn) {
+ GWEN_Buffer_AppendString(tbuf, GWEN_XMLNode_GetData(nn));
+ }
+ else {
+ GWEN_XMLNode_free(xmlNode);
+ return 1;
+ }
+ }
+ GWEN_XMLNode_free(xmlNode);
+ return 0;
+}
+
+#if 0
+void gnc__utf8ToLatin1(const char *utf, int outputlength, char *latin1);
+
+void gnc__utf8ToLatin1(const char *utf, int outputlength, char *latin1)
+{
+ xmlCharEncodingHandlerPtr utf8ptr =
+ xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF8);
+ xmlCharEncodingHandlerPtr latin1ptr =
+ xmlGetCharEncodingHandler(XML_CHAR_ENCODING_8859_1);
+ xmlCharEncodingInputFunc intolatin1 = latin1ptr->input;
+ xmlCharEncodingInputFunc fromutf8 = utf8ptr->output;
+}
+#endif
+
/********************************************************
* Now all the callback functions
*/
static int inputBoxCB(AB_BANKING *ab,
GWEN_TYPE_UINT32 flags,
- const char *title,
- const char *text,
+ const char *utf8title,
+ const char *utf8text,
char *resultbuffer,
int minsize,
int maxLen)
{
GNCInteractor *data;
- char *msgstr = NULL, *passwd = NULL;
+ char *passwd = NULL;
int retval = 0;
int newPin;
int hideInput;
GWEN_BUFFER *buffer1, *buffer2;
- int bufsize = 10+strlen(text);
+ int bufsize = 10+strlen(utf8text);
const char *latin1text;
const char *latin1title;
@@ -221,8 +285,12 @@
buffer1 = GWEN_Buffer_new(0, bufsize, 0, 0);
buffer2 = GWEN_Buffer_new(0, bufsize, 0, 0);
- AB_ImExporter_Utf8ToDta (title, bufsize, buffer1);
- AB_ImExporter_Utf8ToDta (text, bufsize, buffer2);
+
+ gnc__extractText(utf8title, buffer1);
+ gnc__extractText(utf8text, buffer2);
+
+ /* AB_ImExporter_Utf8ToDta (title, bufsize, buffer1); */
+ /* AB_ImExporter_Utf8ToDta (text, bufsize, buffer2); */
latin1title = GWEN_Buffer_GetStart (buffer1);
latin1text = GWEN_Buffer_GetStart (buffer2);
@@ -235,27 +303,25 @@
while (TRUE) {
if (newPin) {
- msgstr = g_strdup_printf("%s\n\n%s", latin1title, latin1text);
retval = gnc_hbci_get_initial_password (data->parent,
- msgstr,
+ latin1title,
+ latin1text,
&passwd);
- g_free (msgstr);
}
else {
- if (data->cache_valid && text && (strcmp(text, data->cache_text)==0)) {
+ if (data->cache_valid && latin1text &&
+ (strcmp(latin1text, data->cache_text)==0)) {
/* Cached user matches, so use cached PIN. */
/*printf("Got the cached PIN for user %s.\n", HBCI_User_userId (user));*/
strcpy(resultbuffer, data->pw);
return 0;
}
else {
- msgstr = g_strdup_printf("%s\n\n%s", latin1title, latin1text);
-
retval = gnc_hbci_get_password (data->parent,
- msgstr,
+ latin1title,
+ latin1text,
NULL,
&passwd);
- g_free (msgstr);
} /* user == data->user */
} /* newPin */
@@ -278,9 +344,9 @@
else {
g_assert (maxLen > strlen(resultbuffer));
strcpy(resultbuffer, passwd);
- if (text && data->cache_pin) {
+ if (latin1text && data->cache_pin) {
/*printf("Cached the PIN for user %s.\n", HBCI_User_userId (user));*/
- data->cache_text = g_strdup(text);
+ data->cache_text= g_strdup(latin1text);
if (data->pw)
g_free (memset (data->pw, 0, strlen (data->pw)));
data->pw = passwd;
@@ -350,12 +416,13 @@
static GWEN_TYPE_UINT32
showBoxCB(AB_BANKING *ab, GWEN_TYPE_UINT32 flags,
- const char *title, const char *text)
+ const char *utf8title, const char *utf8text)
{
char *msgstr;
GtkWidget *dialog;
GNCInteractor *data;
GWEN_TYPE_UINT32 result;
+ const char *title = utf8title, *text = utf8text;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
g_assert(data);
@@ -381,11 +448,12 @@
*/
static int messageBoxCB(AB_BANKING *ab, GWEN_TYPE_UINT32 flags,
- const char *title, const char *text,
+ const char *utf8title, const char *utf8text,
const char *b1, const char *b2, const char *b3)
{
GNCInteractor *data;
GtkWidget *dialog, *label;
+ const char *title = utf8title, *text = utf8text;
int result;
g_assert(ab);
@@ -411,10 +479,11 @@
#define progress_id 4711
-static GWEN_TYPE_UINT32 progressStartCB(AB_BANKING *ab, const char *title,
- const char *text, GWEN_TYPE_UINT32 total)
+static GWEN_TYPE_UINT32 progressStartCB(AB_BANKING *ab, const char *utf8title,
+ const char *utf8text, GWEN_TYPE_UINT32 total)
{
GNCInteractor *data;
+ const char *title = utf8title, *text = utf8text;
//GtkWidget *dialog;
g_assert(ab);
data = AB_Banking_GetUserData(ab);
@@ -460,12 +529,12 @@
static int progressLogCB(AB_BANKING *ab, GWEN_TYPE_UINT32 id,
- AB_BANKING_LOGLEVEL level, const char *text)
+ AB_BANKING_LOGLEVEL level, const char *utf8text)
{
GNCInteractor *data;
//GtkWidget *dialog;
GWEN_BUFFER *buffer;
- int bufsize = 10+strlen(text);
+ int bufsize = 10+strlen(utf8text);
const char *latin1text;
g_assert(ab);
@@ -473,7 +542,8 @@
g_assert(data);
buffer = GWEN_Buffer_new(0, bufsize, 0, 0);
- AB_ImExporter_Utf8ToDta (text, bufsize, buffer);
+ gnc__extractText(utf8text, buffer);
+ /* AB_ImExporter_Utf8ToDta (text, bufsize, buffer); */
latin1text = GWEN_Buffer_GetStart (buffer);
if ((id != 0) && (id != progress_id)) {
Index: gnc-hbci-transfer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-transfer.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lsrc/import-export/hbci/gnc-hbci-transfer.c -Lsrc/import-export/hbci/gnc-hbci-transfer.c -u -r1.19 -r1.20
--- src/import-export/hbci/gnc-hbci-transfer.c
+++ src/import-export/hbci/gnc-hbci-transfer.c
@@ -116,8 +116,11 @@
successful = gnc_hbci_maketrans_final (td, gnc_acc, trans_type);
/* User pressed cancel? Then go back to HBCI transaction */
- if (!successful)
+ if (!successful) {
+ AB_Banking_DequeueJob (api, job);
+ AB_Job_free (job);
continue;
+ }
if (result == 0) {
@@ -132,8 +135,15 @@
xaccTransBeginEdit(gtrans);
xaccTransDestroy(gtrans);
xaccTransCommitEdit(gtrans);
+
+/* AB_Banking_DequeueJob(api, job); */
+/* AB_Banking_DelFinishedJob(api, job); */
+/* AB_Banking_DelPendingJob(api, job); */
}
+ AB_Banking_DequeueJob(api, job);
+ AB_Banking_DelFinishedJob(api, job);
+ AB_Banking_DelPendingJob(api, job);
} /* result == 0 */
else {
/* huh? Only result == 0 should be possible. Simply ignore
Index: gnc-hbci-gettrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-gettrans.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -Lsrc/import-export/hbci/gnc-hbci-gettrans.c -Lsrc/import-export/hbci/gnc-hbci-gettrans.c -u -r1.32 -r1.33
--- src/import-export/hbci/gnc-hbci-gettrans.c
+++ src/import-export/hbci/gnc-hbci-gettrans.c
@@ -110,6 +110,8 @@
if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
/* AB_BANKING_executeOutbox failed. */
AB_Banking_DequeueJob(api, job);
+ AB_Banking_DelFinishedJob(api, job);
+ AB_Banking_DelPendingJob(api, job);
return;
}
@@ -120,7 +122,9 @@
gnc_hbci_gettrans_final(parent, gnc_acc, job, FALSE);
/* Clean up behind ourself. */
+ AB_Banking_DequeueJob(api, job);
AB_Banking_DelFinishedJob(api, job);
+ AB_Banking_DelPendingJob(api, job);
gnc_AB_BANKING_fini (api);
GNCInteractor_hide (interactor);
}
Index: dialog-hbcitrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/dialog-hbcitrans.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lsrc/import-export/hbci/dialog-hbcitrans.c -Lsrc/import-export/hbci/dialog-hbcitrans.c -u -r1.36 -r1.37
--- src/import-export/hbci/dialog-hbcitrans.c
+++ src/import-export/hbci/dialog-hbcitrans.c
@@ -622,27 +622,8 @@
GNC_HBCI_Transtype trans_type)
{
AB_JOB *job;
- const char *jobname;
/* Create a Do-Transaction (Transfer) job. */
- switch (trans_type) {
- case SINGLE_DEBITNOTE:
- {
- jobname = "JobSingleDebitNote";
- }
- break;
- case SINGLE_TRANSFER:
- {
- jobname = "JobSingleTransfer";
- }
- break;
- default:
- {
- /*printf("dialog-hbcitrans: Oops, unknown GNC_HBCI_Transtype %d.\n",
- trans_type);*/
- jobname = "JobSingleTransfer";
- }
- }
job = AB_JobSingleTransfer_new(h_acc);
if (AB_Job_CheckAvailability(job)) {
printf("gnc_hbci_trans_dialog_enqueue: Oops, job not available. Aborting.\n");
Index: gnc-hbci-getbalance.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-getbalance.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -u -r1.28 -r1.29
--- src/import-export/hbci/gnc-hbci-getbalance.c
+++ src/import-export/hbci/gnc-hbci-getbalance.c
@@ -179,12 +179,10 @@
static gchar*
bal_print_balance(const char *format,
- const AB_VALUE *val,
- gboolean negative)
+ const AB_VALUE *val)
{
char *str = gnc_AB_VALUE_toReadableString (val);
char *res = g_strdup_printf(format,
- (negative ? "-" : ""),
str);
free (str);
return res;
@@ -203,7 +201,6 @@
time_t booked_tt;
- gboolean booked_debit, noted_debit;
gboolean dialogres;
response = AB_JobGetBalance_GetAccountStatus((AB_JOB*)job);
@@ -220,10 +217,8 @@
return TRUE;
}
booked_val = AB_Balance_GetValue(booked_grp);
- booked_debit = AB_Value_GetValue(booked_val) < 0;
noted_val = AB_Balance_GetValue(noted_grp);
- noted_debit = AB_Value_GetValue(noted_val) < 0;
booked_tt = GWEN_Time_toTime_t (AB_Balance_GetTime(booked_grp));
@@ -249,24 +244,16 @@
char *booked_str = gnc_AB_VALUE_toReadableString (booked_val);
char *message1 = g_strdup_printf
(
- /* Translators: The first %s is "-" if this amount is
- * negative or "" if it is positive. The second %s is the
- * amount. */
_("Result of HBCI job: \n"
- "Account booked balance is %s%s\n"),
- (booked_debit ? "-" : ""),
+ "Account booked balance is %s\n"),
booked_str);
char *message2 =
((AB_Value_GetValue (noted_val) == 0) ?
g_strdup_printf("%s", "") :
bal_print_balance
- /* Translators: The first %s is "-" if this amount is
- * negative or "" if it is positive. The second %s is the
- * amount. */
(_("For your information: This account also \n"
- "has a noted balance of %s%s\n"),
- noted_val,
- noted_debit));
+ "has a noted balance of %s\n"),
+ noted_val));
const char *message3 = _("Reconcile account now?");
dialogres = gnc_verify_dialog
@@ -283,15 +270,13 @@
if (dialogres)
{
- gnc_numeric abs_value =
+ gnc_numeric value =
double_to_gnc_numeric (AB_Value_GetValue (booked_val),
xaccAccountGetCommoditySCU(gnc_acc),
GNC_RND_ROUND);
recnWindowWithBalance (parent,
gnc_acc,
- (booked_debit
- ? gnc_numeric_neg (abs_value)
- : abs_value),
+ value,
booked_tt);
}
Index: dialog-pass.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/dialog-pass.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lsrc/import-export/hbci/dialog-pass.c -Lsrc/import-export/hbci/dialog-pass.c -u -r1.4 -r1.5
--- src/import-export/hbci/dialog-pass.c
+++ src/import-export/hbci/dialog-pass.c
@@ -31,6 +31,7 @@
gboolean
gnc_hbci_get_password (GtkWidget *parent,
+ const char *windowtitle,
const char *heading,
const char *initial_password,
char **password)
@@ -59,6 +60,9 @@
gnome_dialog_editable_enters (GNOME_DIALOG (dialog),
GTK_EDITABLE (password_entry));
+ if (windowtitle)
+ gtk_window_set_title (GTK_WINDOW (dialog), windowtitle);
+
if (heading)
gtk_label_set_text (GTK_LABEL (heading_label), heading);
@@ -90,6 +94,7 @@
gboolean
gnc_hbci_get_initial_password (GtkWidget *parent,
+ const char *windowtitle,
const char *heading,
char **password)
{
@@ -121,6 +126,9 @@
gnome_dialog_editable_enters (GNOME_DIALOG (dialog),
GTK_EDITABLE (confirm_entry));
+ if (windowtitle)
+ gtk_window_set_title (GTK_WINDOW (dialog), windowtitle);
+
if (heading)
gtk_label_set_text (GTK_LABEL (heading_label), heading);
More information about the gnucash-changes
mailing list