[Gnucash-changes] More HBCI work.

Christian Stimming cstim at cvs.gnucash.org
Sat Oct 2 12:42:56 EDT 2004


Log Message:
-----------
More HBCI work.

Tags:
----
gnucash-1-8-branch

Modified Files:
--------------
    gnucash/po:
        de.po
    gnucash/src/import-export/hbci:
        hbci-interaction.c
        hbci-interaction.h
        hbci-interactionP.h

Revision Data
-------------
Index: de.po
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/po/de.po,v
retrieving revision 1.147.2.48
retrieving revision 1.147.2.49
diff -Lpo/de.po -Lpo/de.po -u -r1.147.2.48 -r1.147.2.49
--- po/de.po
+++ po/de.po
@@ -10,8 +10,8 @@
 msgstr ""
 "Project-Id-Version: de\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2004-09-25 12:23+0200\n"
-"PO-Revision-Date: 2004-09-25 12:27+0200\n"
+"POT-Creation-Date: 2004-10-02 18:44+0200\n"
+"PO-Revision-Date: 2004-10-02 18:45+0200\n"
 "Last-Translator: Christian Stimming <stimming at tuhh.de>\n"
 "Language-Team: German <de at li.org>\n"
 "MIME-Version: 1.0\n"
@@ -7478,7 +7478,7 @@
 msgid "Online Banking & Importing"
 msgstr "Online Banking & Import"
 
-#: src/import-export/hbci/hbci-interaction.c:349
+#: src/import-export/hbci/hbci-interaction.c:341
 #, c-format
 msgid ""
 "The PIN needs to be at least %d characters \n"
@@ -7487,6 +7487,15 @@
 "Die PIN muß mindestens %d Zeichen lang \n"
 "sein.  Erneut versuchen?"
 
+#: src/import-export/hbci/hbci-interaction.c:407
+#, c-format
+msgid ""
+"This TAN needs to be at least %d characters \n"
+"long. Do you want to try again?"
+msgstr ""
+"Diese TAN muß mindestens %d Zeichen lang \n"
+"sein.  Erneut versuchen?"
+
 #: src/import-export/hbci/dialog-hbcitrans.c:334
 msgid "Enter an Online Direct Debit Note"
 msgstr "Online-Lastschrift eingeben"
@@ -7583,7 +7592,7 @@
 msgid "Do you really want to delete the template '%s'?"
 msgstr "Wollen Sie die Vorlage »%s« wirklich löschen?"
 
-#: src/import-export/hbci/gnc-hbci-getbalance.c:234
+#: src/import-export/hbci/gnc-hbci-getbalance.c:253
 msgid ""
 "The downloaded HBCI Balance was zero.\n"
 "Either this is the correct balance, or your bank does not \n"
@@ -7599,7 +7608,7 @@
 "HBCI-Version auswählen. Versuchen Sie anschließend erneut, den Saldo\n"
 "abzufragen.  \n"
 
-#: src/import-export/hbci/gnc-hbci-getbalance.c:247
+#: src/import-export/hbci/gnc-hbci-getbalance.c:266
 #, c-format
 msgid ""
 "Result of HBCI job: \n"
@@ -7608,7 +7617,7 @@
 "Ergebnis des HBCI Auftrag:\n"
 "Gebuchter Saldo des Kontos ist %s\n"
 
-#: src/import-export/hbci/gnc-hbci-getbalance.c:254
+#: src/import-export/hbci/gnc-hbci-getbalance.c:273
 #, c-format
 msgid ""
 "For your information: This account also \n"
@@ -7617,12 +7626,12 @@
 "Zu Ihrer Information: Dieses Konto hat außerdem folgenden \n"
 "Saldo an zur Ausführung vorgemerkten Aufträgen: %s\n"
 
-#: src/import-export/hbci/gnc-hbci-getbalance.c:257
+#: src/import-export/hbci/gnc-hbci-getbalance.c:276
 msgid "Reconcile account now?"
 msgstr "Konto jetzt abgleichen?"
 
-#: src/import-export/hbci/gnc-hbci-gettrans.c:201
-#: src/import-export/hbci/gnc-hbci-gettrans.c:222
+#: src/import-export/hbci/gnc-hbci-gettrans.c:203
+#: src/import-export/hbci/gnc-hbci-gettrans.c:224
 msgid "The HBCI import returned no transactions for the selected time period."
 msgstr "Es liegen keine Buchungen für die gewählte Zeitspanne vor."
 
@@ -12590,7 +12599,9 @@
 
 #: intl-scm/guile-strings.c:2556
 msgid "Include splits with no shares for calculating money-in and money-out"
-msgstr "Buchungsteile ohne Aktien-Anteile trotzdem für Wertzuwachs und -abnahme mit einbeziehen"
+msgstr ""
+"Buchungsteile ohne Aktien-Anteile trotzdem für Wertzuwachs und -abnahme mit "
+"einbeziehen"
 
 #: intl-scm/guile-strings.c:2580 intl-scm/guile-strings.c:3154
 msgid "Gain"
Index: hbci-interaction.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interaction.h,v
retrieving revision 1.6.2.3
retrieving revision 1.6.2.4
diff -Lsrc/import-export/hbci/hbci-interaction.h -Lsrc/import-export/hbci/hbci-interaction.h -u -r1.6.2.3 -r1.6.2.4
--- src/import-export/hbci/hbci-interaction.h
+++ src/import-export/hbci/hbci-interaction.h
@@ -38,6 +38,7 @@
 void GNCInteractor_delete(GNCInteractor *i);
 void GNCInteractor_erasePIN(GNCInteractor *i);
 void GNCInteractor_reparent (GNCInteractor *i, GtkWidget *new_parent);
+gboolean GNCInteractor_get_cache_valid(const GNCInteractor *i);
 void GNCInteractor_set_cache_valid(GNCInteractor *i, gboolean value);
 GtkWidget *GNCInteractor_parent(GNCInteractor *i);
 void GNCInteractor_add_log_text (GNCInteractor *i, const char *msg);
Index: hbci-interactionP.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interactionP.h,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -Lsrc/import-export/hbci/hbci-interactionP.h -Lsrc/import-export/hbci/hbci-interactionP.h -u -r1.4.2.3 -r1.4.2.4
--- src/import-export/hbci/hbci-interactionP.h
+++ src/import-export/hbci/hbci-interactionP.h
@@ -70,11 +70,6 @@
 
   /* Flag on Whether the PIN should be cached. */
   gboolean cache_pin;
-  /* The cached PIN and the HBCI_User it's cached for. */
-  char *pw;
-  char *cache_text;
-  /* Whether this PIN is really valid or not. */
-  gboolean cache_valid;
 
   /* Dialogs */
   int showbox_id;
Index: hbci-interaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interaction.c,v
retrieving revision 1.16.2.15
retrieving revision 1.16.2.16
diff -Lsrc/import-export/hbci/hbci-interaction.c -Lsrc/import-export/hbci/hbci-interaction.c -u -r1.16.2.15 -r1.16.2.16
--- src/import-export/hbci/hbci-interaction.c
+++ src/import-export/hbci/hbci-interaction.c
@@ -57,7 +57,6 @@
   data->gnc_iconv_handler = iconv_open("ISO8859-1", "UTF-8");
   g_assert(data->gnc_iconv_handler != (iconv_t)(-1));
   data->keepAlive = TRUE;
-  data->cache_valid = FALSE;
   data->cache_pin = 
     gnc_lookup_boolean_option(PREF_TAB_ONLINE_BANKING,
 			      "HBCI Remember PIN in memory",
@@ -147,6 +146,7 @@
 
   /* Make sure the cache_pin option is up to date. */
   if (cache_pin != i->cache_pin) {
+    /* AB_Banking_SetEnablePinCaching (ab, cache_pin); */
     i->cache_pin = cache_pin;
     if (cache_pin == FALSE)
       GNCInteractor_erasePIN (i);
@@ -172,20 +172,21 @@
 			  (GTK_TOGGLE_BUTTON (i->close_checkbutton)));
 }
 
+gboolean GNCInteractor_get_cache_valid(const GNCInteractor *i)
+{
+  g_assert(i);
+  return i->cache_pin;
+}
 void GNCInteractor_set_cache_valid(GNCInteractor *i, gboolean value)
 {
   g_assert(i);
-  i->cache_valid = value;
+  /* Nothing to be done right now. */
 }
 
 void GNCInteractor_erasePIN(GNCInteractor *i)
 {
   g_assert(i);
-  if (i->pw != NULL)
-    g_free (memset (i->pw, 0, strlen (i->pw)));
-  i->pw = NULL;
-  i->cache_valid = FALSE;
-  /* i->user = NULL; */
+  /* Nothing to be done right now. */
 }
 void GNCInteractor_reparent (GNCInteractor *i, GtkWidget *new_parent)
 {
@@ -323,21 +324,12 @@
 					      &passwd);
     }
     else {
-      if (data->cache_valid && text && data->cache_text &&
-	  (strcmp(text, data->cache_text)==0)) {
-	/* Cached user matches, so use cached PIN. */
-	/*printf("Got the cached PIN for user %s.\n", HBCI_User_userId (user));*/
-	strcpy(resultbuffer, data->pw);
-	return 0;
-      }
-      else {
-	retval = gnc_hbci_get_password (data->parent,
-					title,
-					text,
-					NULL,
-					&passwd,
-					hideInput);
-      } /* user == data->user */
+      retval = gnc_hbci_get_password (data->parent,
+				      title,
+				      text,
+				      NULL,
+				      &passwd,
+				      hideInput);
     } /* newPin */
     
     if (!retval)
@@ -359,17 +351,74 @@
     else {
       g_assert (maxLen > strlen(resultbuffer));
       strcpy(resultbuffer, passwd);
-      /* Watch out: If we only compare the user string, then don't
-	 cache this if a TAN is asked for. */
-      if (text && data->cache_pin && !(strstr(text, "TAN"))) {
-	/*printf("Cached the PIN for user %s.\n", HBCI_User_userId (user));*/
-	data->cache_text= g_strdup(text);
-	if (data->pw)
-	  g_free (memset (data->pw, 0, strlen (data->pw)));
-	data->pw = passwd;
-      }
-      else 
-	g_free (memset (passwd, 0, strlen (passwd)));
+      g_free (memset (passwd, 0, strlen (passwd)));
+      g_free(title);
+      g_free(text);
+      return 0;
+    }
+  }
+  
+  /* User wanted to abort. */
+  g_free(title);
+  g_free(text);
+  return 1;
+}
+
+/* **************************************** 
+ */
+
+
+static int getTanCB(AB_BANKING *ab,
+		    const char *token,
+		    const char *utf8title,
+		    const char *utf8text,
+		    char *resultbuffer,
+		    int minsize,
+		    int maxLen)
+{
+  GNCInteractor *data;
+  char *passwd = NULL;
+  int retval = 0;
+  gchar *title, *text;
+
+  g_assert(ab);
+  data = AB_Banking_GetUserData(ab);
+  g_assert(data);
+  g_assert(maxLen > minsize);
+
+  text = gnc_hbci_utf8ToLatin1(data, utf8text);
+  title = gnc_hbci_utf8ToLatin1(data, utf8title);
+
+  while (TRUE) {
+
+    retval = gnc_hbci_get_password (data->parent,
+				    title,
+				    text,
+				    NULL,
+				    &passwd,
+				    FALSE);
+
+    if (!retval)
+      break;
+    
+    if (strlen(passwd) < (unsigned int)minsize) {
+      gboolean retval;
+      char *msg = 
+	g_strdup_printf (  _("This TAN needs to be at least %d characters \n"
+			     "long. Do you want to try again?"),
+			   minsize);
+      retval = gnc_verify_dialog_parented (GTK_WIDGET (data->parent), 
+					   TRUE,
+					   msg);
+      g_free (msg);
+      if (!retval)
+	break;
+    }
+    else {
+      g_assert (maxLen > strlen(resultbuffer));
+      strcpy(resultbuffer, passwd);
+
+      g_free (memset (passwd, 0, strlen (passwd)));
       g_free(title);
       g_free(text);
       return 0;
@@ -382,6 +431,10 @@
   return 1;
 }
 
+
+/* ************************************************************ 
+ */
+
 static int keepAlive(void *user_data)
 {
   GNCInteractor *data = user_data;
@@ -401,14 +454,10 @@
   if (data == NULL)
     return;
 
-  if (data->pw) {
-    memset (data->pw, 0, strlen(data->pw));
-    g_free (data->pw);
-    data->pw = NULL;
-  }
   GNCInteractor_delete (data);
 }
 
+
 /* ************************************************************ 
  */
 
@@ -516,6 +565,7 @@
   return result+1;
 }
 
+
 /* ************************************************************ 
  */
 
@@ -727,6 +777,9 @@
   AB_Banking_SetProgressLogFn(ab, progressLogCB);
   AB_Banking_SetProgressEndFn(ab, progressEndCB);
 
+  /* AB_Banking_SetGetPinFn(ab,); */
+  AB_Banking_SetGetTanFn(ab, getTanCB);
+
   AB_Banking_SetUserData(ab, data);
 
 }


More information about the gnucash-changes mailing list