2002-08-10 Christian Stimming <stimming@tuhh.de>

* src/import-export/hbci/hbci-interaction.[hc]: Add code for
	HBCI_API interaction. Will be migrated to gnucash-UI's code
	soon. Recent changes to HBCI code require yet another update to
	current OpenHBCI CVS.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7152 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2002-08-10 16:47:33 +00:00
parent b7a50164dd
commit eb331873c4
8 changed files with 948 additions and 140 deletions

View File

@@ -1,5 +1,10 @@
2002-08-10 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/hbci-interaction.[hc]: Add code for
HBCI_API interaction. Will be migrated to gnucash-UI's code
soon. Recent changes to HBCI code require yet another update to
current OpenHBCI CVS.
* src/import-export/hbci/*: Add druid-hbci-utils.[hc], implement
more parts of HBCI setup. Requires update to current OpenHBCI CVS,
though.

View File

@@ -7,6 +7,7 @@ libgncmod_hbci_la_SOURCES = \
druid-hbci-utils.c \
gnc-hbci-kvp.c \
gnc-hbci-utils.c \
hbci-interaction.c \
hbci-account-picker.c \
druid-hbci-initial.c

View File

@@ -49,7 +49,17 @@
/* #include "top-level.h" */
#include <openhbci/api.h>
#include <openhbci/outboxjobs.h>
#include <openhbci/outboxjobkeys.h>
#include <openhbci/mediumrdh.h>
typedef enum _infostate {
INI_ADD_BANK,
INI_ADD_USER,
INI_MATCH_ACCOUNTS,
ADD_BANK,
ADD_USER,
MATCH_ACCOUNTS
} Infostate;
struct _hbciinitialinfo
{
@@ -81,7 +91,11 @@ struct _hbciinitialinfo
/* iniletter server */
GtkWidget *serverpage;
GtkWidget *server_text;
GtkWidget *server_bankcode;
GtkWidget *server_ip;
GtkWidget *server_exp;
GtkWidget *server_mod;
GtkWidget *server_hash;
/* iniletter user */
GtkWidget *user_text;
@@ -93,7 +107,12 @@ struct _hbciinitialinfo
GHashTable *hbci_hash;
/* hbci_account (direct) -> gnucash_account -- DO NOT DELETE THE KEYS! */
GHashTable *gnc_hash;
/* Status of user's movement through the wizard */
Infostate state;
/* Newly created customer */
HBCI_Customer *newcustomer;
};
static gboolean
@@ -128,7 +147,8 @@ delete_initial_druid (HBCIInitialInfo *info)
delete_hash (info->hbci_hash);
info->hbci_hash = NULL;
g_hash_table_destroy (info->gnc_hash);
if (info->gnc_hash != NULL)
g_hash_table_destroy (info->gnc_hash);
info->gnc_hash = NULL;
}
@@ -181,7 +201,7 @@ update_accountlist_acc_cb (const HBCI_Account *hacc, gpointer user_data)
return NULL;
}
static gpointer
update_accountlist_bankcb (const HBCI_Bank *bank, gpointer user_data)
update_accountlist_bank_cb (const HBCI_Bank *bank, gpointer user_data)
{
g_assert(bank);
@@ -220,7 +240,7 @@ update_accountlist (HBCIInitialInfo *info)
/* Go through all HBCI banks */
list_HBCI_Bank_foreach (banklist,
&update_accountlist_bankcb,
&update_accountlist_bank_cb,
info);
//printf("HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash));
@@ -286,21 +306,26 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
return TRUE;
}
if (strcmp(filename,
gnc_hbci_get_book_configfile (gnc_get_current_book ())) != 0) {
gnc_hbci_set_book_configfile (gnc_get_current_book (), filename);
}
if (info->api) {
HBCI_API_delete (info->api);
info->api = NULL;
{
if (strcmp(filename,
gnc_hbci_get_book_configfile (gnc_get_current_book ())) != 0) {
/* Name of configfile has changed */
gnc_hbci_set_book_configfile (gnc_get_current_book (), filename);
if (info->api != NULL)
HBCI_API_delete (info->api);
/* Create new HBCI_API object, loading its data from filename */
info->api = gnc_hbci_api_new (filename, TRUE);
}
else if (info->api == NULL)
/* Create new HBCI_API object, loading its data from filename */
info->api = gnc_hbci_api_new (filename, TRUE);
api = info->api;
g_free (filename);
if (api == NULL)
return TRUE;
}
/* Create new HBCI_API object, loading its data from filename */
api = gnc_hbci_api_new (filename);
g_free (filename);
info->api = api;
/* Get HBCI bank and account list */
{
const list_HBCI_Bank *banklist;
@@ -309,11 +334,13 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
//printf("%d banks found.\n", list_HBCI_Bank_size (banklist));
if (list_HBCI_Bank_size (banklist) == 0) {
// Zero banks? go to next page (create_bank)
info->state = INI_ADD_BANK;
return FALSE;
}
if (HBCI_API_totalUsers(api) == 0) {
// zero users? go to user-creation page
info->state = INI_ADD_USER;
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->userpage));
return TRUE;
@@ -325,12 +352,75 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage,
}
}
info->state = INI_MATCH_ACCOUNTS;
// accounts already exist? Then go to account matching page
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->accountpage));
return TRUE;
}
static gboolean
on_bankpage_back (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
g_assert(info);
switch (info->state) {
case INI_ADD_BANK:
return FALSE;
case ADD_BANK:
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->accountpage));
return TRUE;
default:
}
return FALSE;
}
static gboolean
on_userid_back (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
g_assert(info);
switch (info->state) {
case INI_ADD_BANK:
case ADD_BANK:
return FALSE;
case INI_ADD_USER:
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->filepage));
return TRUE;
case ADD_USER:
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->accountpage));
return TRUE;
default:
}
return FALSE;
}
static gboolean
on_userid_focus_out (GtkWidget *widget,
GdkEventFocus *event,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
const char *userid = NULL;
const char *customerid = NULL;
g_assert(info);
userid = gtk_entry_get_text (GTK_ENTRY (info->userid));
customerid = gtk_entry_get_text (GTK_ENTRY (info->customerid));
if (strlen(customerid)==0)
gtk_entry_set_text (GTK_ENTRY (info->customerid), userid);
return FALSE;
}
static gboolean
on_userid_next (GnomeDruidPage *gnomedruidpage,
@@ -361,7 +451,16 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
if (bank == NULL) {
printf("on_userid_next: Creating bank with code %s.\n", bankcode);
bank = HBCI_API_bankFactory (api, countrycode, bankcode, ipaddr);
HBCI_API_addBank (api, bank, TRUE);
{
HBCI_Error *err;
err = HBCI_API_addBank (api, bank, TRUE);
if (err != NULL) {
printf("on_userid_next-CRITICAL: Error at addBank: %s.\n",
HBCI_Error_message (err));
HBCI_Error_delete (err);
return TRUE;
}
}
}
else {
printf("on_userid_next: Found bank, name %s.\n", HBCI_Bank_name(bank));
@@ -369,10 +468,12 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
user = HBCI_Bank_findUser(bank, userid);
if (user == NULL) {
gboolean is_rdh, mount_test;
gboolean is_rdh;
HBCI_Medium *medium;
HBCI_User *newuser;
HBCI_Customer *cust;
HBCI_Error *err;
char *mediumname;
int secmode;
printf("on_userid_next: Didn't find user with userid %s.\n", userid);
is_rdh = gtk_toggle_button_get_active
@@ -380,85 +481,89 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
if (is_rdh) {
/* Create RDH Medium */
char *mediumpath;
mediumpath = gnome_file_entry_get_full_path
mediumname = gnome_file_entry_get_full_path
(GNOME_FILE_ENTRY (info->mediumpath), FALSE);
// Some sanity checks on the filename
if (!gnc_verify_exist_or_new_file
(GTK_WIDGET (info->window), mediumpath)) {
g_free (mediumpath);
(GTK_WIDGET (info->window), mediumname)) {
g_free (mediumname);
return TRUE;
}
if (!gnc_test_dir_exist_error (GTK_WINDOW (info->window),
mediumpath)) {
g_free (mediumpath);
mediumname)) {
g_free (mediumname);
return TRUE;
}
printf("on_userid_next: About to Create user with RDH medium and userid %s.\n", userid);
medium = HBCI_API_createNewMedium (api,
countrycode, bankcode, userid,
mediumpath, HBCI_SECURITY_RDH);
printf("on_userid_next: Created user with RDH medium and userid %s.\n", userid);
g_free(mediumpath);
g_assert(medium);
newuser = HBCI_API_userFactory (bank, medium, TRUE, userid);
g_assert(newuser);
HBCI_Bank_addUser (bank, newuser, TRUE);
secmode = HBCI_SECURITY_RDH;
}
{
/* Create DDV Medium */
mediumname = g_strdup("");
secmode = HBCI_SECURITY_DDV;
}
mount_test = HBCI_Medium_mountMedium (medium, newuser);
HBCI_Medium_unmountMedium (medium);
if (mount_test) {
printf("on_userid_next: Mounting RDH medium was successful.\n");
}
else {
printf("on_userid_next: Mounting RDH medium failed.\n");
return TRUE;
}
medium = HBCI_API_createNewMedium (api,
countrycode, bankcode, userid,
mediumname, secmode, &err);
g_free(mediumname);
if (medium == NULL) {
printf("on_userid_next: Couldn't create medium: %s",
HBCI_Error_message (err));
HBCI_Error_delete (err);
return TRUE;
}
newuser = HBCI_API_userFactory (bank, medium, TRUE, userid);
printf("on_userid_next: Created user with userid %s.\n",
userid);
g_assert(newuser);
err = HBCI_Bank_addUser (bank, newuser, TRUE);
if (err != NULL) {
printf("on_userid_next-CRITICAL: Error at addUser: %s.\n",
HBCI_Error_message (err));
HBCI_Error_delete (err);
return TRUE;
}
{
err = HBCI_Medium_mountMedium (medium, newuser);
if (err != NULL) {
printf("on_userid_next: Mounting medium failed: %s.\n",
HBCI_Error_message (err));
HBCI_Error_delete (err);
return TRUE;
}
printf("on_userid_next: Mounting medium was successful.\n");
HBCI_Medium_unmountMedium (medium);
}
{
HBCI_Customer *cust;
cust = HBCI_API_customerFactory (newuser, customerid,
"Default Customer");
g_assert (cust);
HBCI_User_addCustomer (newuser, cust, TRUE);
info->newcustomer = cust;
}
if (is_rdh) {
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->serverpage));
return TRUE;
}
// DDV Medium
medium = HBCI_API_createNewMedium (api,
countrycode, bankcode, userid,
"", HBCI_SECURITY_DDV);
g_assert(medium);
printf("on_userid_next: Creating user with DDV medium and userid %s.\n", userid);
newuser = HBCI_API_userFactory (bank, medium, TRUE, userid);
g_assert(newuser);
HBCI_Bank_addUser (bank, newuser, TRUE);
mount_test = HBCI_Medium_mountMedium (medium, newuser);
HBCI_Medium_unmountMedium (medium);
if (mount_test) {
printf("on_userid_next: Mounting DDV medium was successful.\n");
}
else {
printf("on_userid_next: Mounting DDV medium failed.\n");
return TRUE;
}
cust = HBCI_API_customerFactory (newuser, customerid,
"Default Customer");
g_assert (cust);
HBCI_User_addCustomer (newuser, cust, TRUE);
return FALSE;
}
else
return FALSE;
}
else {
printf("on_userid_next: Found user, name %s.\n", HBCI_User_userName(user));
}
info->state = MATCH_ACCOUNTS;
return FALSE;
}
@@ -469,27 +574,105 @@ on_iniletter_server_back (GnomeDruidPage *gnomedruidpage,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
g_assert(info->druid);
g_assert(info->userpage);
g_assert(info);
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->userpage));
return TRUE;
}
static char *
to_hexstring (const char *str)
{
int i, bytes = strlen(str)/2;
char *res = g_strnfill (3*bytes, ' ');
for (i=0; i < bytes; i++) {
res[3*i+0] = str[2*i+0];
res[3*i+1] = str[2*i+1];
if (i % 16 == 15)
res[3*i+2] = '\n';
}
res [3*i+2] = '\0';
printf ("Converted -%s- to -%s-.\n", str, res);
return res;
}
static void
on_iniletter_server_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
GtkEditable *text = GTK_EDITABLE (info->server_text);
const char *mytext = "abcdefg";
gint *pos;
pos = g_new0(gint,1);
HBCI_OutboxJobGetKeys *job;
HBCI_Error *err;
g_assert(info);
if (info->newcustomer == NULL)
return;
gnome_druid_set_buttons_sensitive (GNOME_DRUID (info->druid),
TRUE, FALSE, TRUE);
gtk_entry_set_text (GTK_ENTRY (info->server_bankcode),
HBCI_Bank_bankCode
(HBCI_User_bank
(HBCI_Customer_user(info->newcustomer))));
gtk_entry_set_text (GTK_ENTRY (info->server_ip),
HBCI_Bank_addr
(HBCI_User_bank
(HBCI_Customer_user(info->newcustomer))));
gtk_editable_insert_text (text, mytext, strlen(mytext), pos);
job = HBCI_OutboxJobGetKeys_new (info->api, info->newcustomer);
HBCI_API_addJob (info->api, HBCI_OutboxJobGetKeys_OutboxJob (job));
err = HBCI_API_executeQueue (info->api, TRUE);
if (!HBCI_Error_isOk(err)) {
printf("on_iniletter_server_prepare: Error at executeQueue: %s\n",
HBCI_Error_message (err));
HBCI_Error_delete (err);
return;
}
HBCI_Error_delete (err);
{
gint *pos;
const HBCI_Medium *med;
const HBCI_MediumRDH *medr;
gboolean has_signkey;
char *tmp, *hash, *exponent, *modulus;
med = HBCI_User_medium (HBCI_Customer_user(info->newcustomer));
medr = HBCI_Medium_MediumRDH ((HBCI_Medium *)med);
g_assert (medr);
has_signkey = HBCI_MediumRDH_has_instPubSignKey (medr);
tmp = HBCI_MediumRDH_getInstIniLetterHash(medr, has_signkey);
hash = to_hexstring (tmp);
free (tmp);
tmp = HBCI_MediumRDH_getInstIniLetterExponent(medr, has_signkey);
exponent = to_hexstring (tmp);
free (tmp);
tmp = HBCI_MediumRDH_getInstIniLetterModulus(medr, has_signkey);
modulus = to_hexstring (tmp);
free (tmp);
pos = g_new0(gint,1);
*pos = 0;
gtk_editable_insert_text (GTK_EDITABLE (info->server_exp),
exponent, strlen(exponent), pos);
*pos = 0;
gtk_editable_insert_text (GTK_EDITABLE (info->server_mod),
modulus, strlen(modulus), pos);
*pos = 0;
gtk_editable_insert_text (GTK_EDITABLE (info->server_hash),
hash, strlen(hash), pos);
g_free (exponent);
g_free (modulus);
g_free (hash);
g_free(pos);
}
g_free(pos);
}
static gboolean
on_iniletter_server_next (GnomeDruidPage *gnomedruidpage,
@@ -511,6 +694,30 @@ on_iniletter_user_next (GnomeDruidPage *gnomedruidpage,
static gboolean
on_accountlist_back (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
g_assert(info);
switch (info->state) {
case INI_ADD_BANK:
case INI_ADD_USER:
case ADD_BANK:
case ADD_USER:
return FALSE;
case INI_MATCH_ACCOUNTS:
case MATCH_ACCOUNTS:
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->filepage));
return TRUE;
default:
}
return FALSE;
}
static void
on_accountlist_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
@@ -562,16 +769,22 @@ on_button_clicked (GtkButton *button,
name = gtk_widget_get_name (GTK_WIDGET (button));
if (strcmp (name, "addbank_button") == 0) {
info->state = ADD_BANK;
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->bankpage));
} else if (strcmp (name, "adduser_button") == 0) {
info->state = ADD_USER;
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->userpage));
} else if (strcmp (name, "updatelist_button") == 0) {
info->state = MATCH_ACCOUNTS;
update_accounts (info->api);
// Nothing else to do.
//gnome_druid_set_page (GNOME_DRUID (info->druid),
// GNOME_DRUID_PAGE (info->accountpage));
} else if (strcmp (name, "serveryes_button") == 0) {
gnome_druid_set_buttons_sensitive (GNOME_DRUID (info->druid),
TRUE, TRUE, TRUE);
} else {
printf("on_button_clicked: Oops, unknown button: %s\n",
name);
@@ -629,16 +842,25 @@ void gnc_hbci_initial_druid (void)
info->bankcode = glade_xml_get_widget(xml, "bank_code_entry");
info->countrycode = glade_xml_get_widget(xml, "country_code_entry");
info->ipaddr = glade_xml_get_widget(xml, "ip_address_entry");
//info->port = glade_xml_get_widget(xml, "port_nr_entry");
gtk_signal_connect (GTK_OBJECT (page), "back",
GTK_SIGNAL_FUNC (on_bankpage_back), info);
}
{
page = glade_xml_get_widget(xml, "user_page");
info->userpage = page;
info->userid = glade_xml_get_widget(xml, "user_id_entry");
gtk_signal_connect (GTK_OBJECT (info->userid), "focus-out-event",
GTK_SIGNAL_FUNC (on_userid_focus_out), info);
info->customerid = glade_xml_get_widget(xml, "customer_id_entry");
info->mediumrdh = glade_xml_get_widget(xml, "rdh_radiobutton");
info->mediumpath = glade_xml_get_widget(xml, "keyfile_fileentry");
info->mediumddv = glade_xml_get_widget(xml, "ddv_radiobutton");
// no libchipcard? Make that button greyed out
if (! HBCI_Hbci_hasLibchipcard ())
gtk_widget_set_sensitive (GTK_WIDGET (info->mediumddv),
FALSE);
gtk_signal_connect (GTK_OBJECT (page), "back",
GTK_SIGNAL_FUNC (on_userid_back), info);
gtk_signal_connect (GTK_OBJECT (page), "next",
GTK_SIGNAL_FUNC (on_userid_next), info);
}
@@ -662,11 +884,21 @@ void gnc_hbci_initial_druid (void)
GTK_SIGNAL_FUNC (on_button_clicked), info);
gtk_signal_connect (GTK_OBJECT (page), "prepare",
GTK_SIGNAL_FUNC (on_accountlist_prepare), info);
gtk_signal_connect (GTK_OBJECT (page), "back",
GTK_SIGNAL_FUNC (on_accountlist_back), info);
}
{
info->server_text = glade_xml_get_widget(xml, "iniletter_server_text");
page = glade_xml_get_widget(xml, "iniletter_server_page");
info->serverpage = page;
gtk_signal_connect (GTK_OBJECT
(glade_xml_get_widget (xml, "serveryes_button")),
"clicked",
GTK_SIGNAL_FUNC (on_button_clicked), info);
info->server_bankcode = glade_xml_get_widget(xml, "bankcode_entryview");
info->server_ip = glade_xml_get_widget(xml, "ipaddress_entryview");
info->server_exp = glade_xml_get_widget(xml, "serverexponent_text");
info->server_mod = glade_xml_get_widget(xml, "servermodulus_text");
info->server_hash = glade_xml_get_widget(xml, "serverhash_text");
gtk_signal_connect (GTK_OBJECT (page), "prepare",
GTK_SIGNAL_FUNC (on_iniletter_server_prepare), info);
gtk_signal_connect (GTK_OBJECT (page), "back",

View File

@@ -44,9 +44,18 @@
<class>GnomeDruidPageStart</class>
<name>druidpagestart1</name>
<title>Initial HBCI Setup</title>
<text>This druid will help you setting up your HBCI connection to your bank.
<text>This druid helps you setting up your HBCI connection with your bank.
Click 'Cancel' if you do not wish to setup any
You first need to apply for HBCI access at your bank. If your bank
decides to grant you HBCI access, the bank will send you a letter,
containing
* The bank code of your bank
* The user ID that identifies you to your bank
* The Internet address of your bank's HBCI server
* Information about the cryptographic public key of your bank (&quot;Ini-Letter&quot;).
This information will be needed in the following. Press 'Next' now.
Press 'Cancel' if you do not wish to setup any
HBCI connection now.</text>
<title_color>255,255,255</title_color>
<text_color>0,0,0</text_color>
@@ -241,7 +250,7 @@ HBCI connection now.</text>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>8</text_max_length>
<text>12345678</text>
<text>10000000</text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
@@ -852,10 +861,9 @@ Press 'Finish' now.</text>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDruidPageStandard:vbox</child_name>
<name>vbox132</name>
<border_width>10</border_width>
<name>druid-vbox8</name>
<homogeneous>False</homogeneous>
<spacing>5</spacing>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
@@ -863,11 +871,10 @@ Press 'Finish' now.</text>
</child>
<widget>
<class>GtkFrame</class>
<name>initletter_server_frame</name>
<label>Ini-Letter Server</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<class>GtkVBox</class>
<name>vbox145</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
@@ -875,43 +882,334 @@ Press 'Finish' now.</text>
</child>
<widget>
<class>GtkScrolledWindow</class>
<name>iniletter_server_textwindow</name>
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<class>GtkFrame</class>
<name>frame60</name>
<border_width>10</border_width>
<label>Ini-Letter Server</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>GtkText</class>
<name>iniletter_server_text</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text></text>
<class>GtkVBox</class>
<name>vbox146</name>
<border_width>10</border_width>
<homogeneous>False</homogeneous>
<spacing>2</spacing>
<widget>
<class>GtkTable</class>
<name>table4</name>
<rows>2</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>2</row_spacing>
<column_spacing>0</column_spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<name>bankcode_entryview</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>ipaddress_entryview</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477416</name>
<label>Internet Address</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>10</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477415</name>
<label>Bank Code</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>10</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator1</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477412</name>
<label>Exponent</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow26</name>
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkText</class>
<name>serverexponent_text</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text></text>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477413</name>
<label>Modulus</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow27</name>
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkText</class>
<name>servermodulus_text</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text></text>
</widget>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator2</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477414</name>
<label>Hash</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow28</name>
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkText</class>
<name>serverhash_text</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text></text>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477404</name>
<label>Please compare the information of this Ini-Letter to the one that your bank gave to you on paper.
<widget>
<class>GtkHBox</class>
<name>hbox113</name>
<border_width>10</border_width>
<homogeneous>False</homogeneous>
<spacing>10</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
If the information (especially the Hash Value) is identical, then press 'Next'.
<widget>
<class>GtkLabel</class>
<name>label8477411</name>
<label>Do these values match the values on your paper Ini-Letter?</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>
If the information is not identical, then please print out the above information,
press 'Cancel', and contact your bank.</label>
<justify>GTK_JUSTIFY_LEFT</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>
<class>GtkButton</class>
<name>serveryes_button</name>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_YES</stock_button>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>serverno_button</name>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_NO</stock_button>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
</widget>

View File

@@ -29,21 +29,25 @@
#include "gnc-hbci-kvp.h"
#include "gnc-ui-util.h"
#include "hbci-interaction.h"
HBCI_API *
gnc_hbci_api_new (const char *filename)
gnc_hbci_api_new (const char *filename, gboolean allowNewFile)
{
HBCI_API *api = NULL;
HBCI_Error *err = NULL;
char *errstring;
if (!filename ||
!g_file_test (filename, G_FILE_TEST_ISFILE | G_FILE_TEST_ISLINK))
if (!filename)
return NULL;
if (!allowNewFile &&
(!g_file_test (filename, G_FILE_TEST_ISFILE | G_FILE_TEST_ISLINK)))
return NULL;
api = HBCI_API_new (FALSE, TRUE);
err = HBCI_API_loadEnvironment (api, filename);
if (!HBCI_Error_isOk (err)) {
if (!HBCI_Error_isOk (err) && !allowNewFile) {
errstring = HBCI_Error_errorString (err);
HBCI_Error_delete (err);
gnc_error_dialog
@@ -53,6 +57,13 @@ gnc_hbci_api_new (const char *filename)
return NULL;
}
HBCI_Error_delete (err);
// set HBCI_Interactor
HBCI_Hbci_setInteractor(HBCI_API_Hbci(api),
gnc_hbci_new_interactor(), TRUE);
// Set HBCI_Progressmonitor
HBCI_API_setMonitor(api, gnc_hbci_new_pmonitor(), TRUE);
return api;
};
@@ -60,7 +71,7 @@ gnc_hbci_api_new (const char *filename)
HBCI_API * gnc_hbci_api_new_currentbook (void)
{
return gnc_hbci_api_new
(gnc_hbci_get_book_configfile (gnc_get_current_book ()));
(gnc_hbci_get_book_configfile (gnc_get_current_book ()), FALSE);
};

View File

@@ -30,14 +30,17 @@
#include "gnc-book.h"
/* Create a new HBCI_API and let it load its environment from the
* configuration file filename. If the file doesn't exist, this
* function returns NULL. If the file exists, but OpenHBCI encountered
* an error upon opening, then an error will be displayed, and NULL
* will be returned.*/
HBCI_API * gnc_hbci_api_new (const char *filename);
* configuration file filename. If the file doesn't exist and
* allowNewFile is set to FALSE, this function returns NULL. If the
* file exists, but OpenHBCI encountered an error upon opening, then
* an error will be displayed, and NULL will be returned.*/
HBCI_API * gnc_hbci_api_new (const char *filename,
gboolean allowNewFile);
/* Same as above, but takes the filename already from the current
book's kvp frame. */
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. */
HBCI_API * gnc_hbci_api_new_currentbook (void);

View File

@@ -0,0 +1,222 @@
/* hbci-interaction.c
Copyright 2002 by Christian Stimming <stimming@tuhh.de> */
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
* *
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include "hbci-interaction.h"
#include <openhbci/interactorcb.h>
#include <openhbci/progressmonitorcb.h>
#define LOCALSIZE 1024
static int msgInputPin(const HBCI_User *user,
char *pinbuf,
int bufsize,
int minsize,
int newPin)
{
const HBCI_Bank * b;
char localbuf[LOCALSIZE];
printf("Pineingabe fuer ");
if (user) {
b=HBCI_User_bank(user);
if (b) {
printf("BLZ %s", HBCI_Bank_bankCode(b));
}
else
printf("<unbekannte Bank>");
printf(", Benutzerkennung %s", HBCI_User_userId(user));
} // if user is valid
else
printf("<unbekannter User>");
printf("\n");
// FIXME: only show asterisks, dont use gets !
gets(localbuf);
strncpy(pinbuf, localbuf, bufsize);
memset(localbuf, 0, LOCALSIZE);
// done
return 1;
}
static int msgInsertCardOrAbort(const HBCI_User *user)
{
const HBCI_Bank * b;
printf("Bitte Karte einlegen fuer ");
if (user) {
b=HBCI_User_bank(user);
if (b) {
printf("BLZ %s", HBCI_Bank_bankCode(b));
}
else
printf("<unbekannte Bank>");
} // if user is valid
else
printf("<unbekannter User>");
printf("\n");
printf("<Bitte druecken Sie ENTER>\n");
getchar();
return 1;
}
static int msgInsertCorrectCardOrAbort(const HBCI_User *user)
{
const HBCI_Bank *b;
printf("Bitte korrekte Karte einlegen fuer ");
if (user) {
b=HBCI_User_bank(user);
if (b) {
printf("BLZ %s", HBCI_Bank_bankCode(b));
}
else
printf("<unbekannt Bank>");
} // if user is valid
else
printf("<unbekannt Bank>");
printf("\n");
printf("<Bitte druecken Sie ENTER>\n");
getchar();
return 1;
}
static void msgStateResponse(const char *msg)
{
fprintf(stdout,"my-msgStateResponse: %s\n",msg);
}
static int keepAlive()
{
//fprintf(stdout, "my-keepAlive: returning 1\n");
return 1;
}
HBCI_Interactor *
gnc_hbci_new_interactor()
{
HBCI_InteractorCB *inter;
inter = HBCI_InteractorCB_new();
HBCI_InteractorCB_setMsgInputPin(inter, &msgInputPin);
HBCI_InteractorCB_setMsgInsertCardOrAbort(inter, &msgInsertCardOrAbort);
HBCI_InteractorCB_setMsgInsertCorrectCardOrAbort(
inter,
&msgInsertCorrectCardOrAbort);
HBCI_InteractorCB_setMsgStateResponse(inter,
&msgStateResponse);
HBCI_InteractorCB_setKeepalive(inter,
&keepAlive) ;
return HBCI_InteractorCB_Interactor(inter);
}
/* ---------------------------------------------------------- */
static void jobStarted(JobProgressType type, int actions)
{
const char *msg;
switch(type){
case JOB_OPENINGDIALOG:
msg = "Er<EFBFBD>ffne Dialog";
break;
case JOB_CLOSINGDIALOG:
msg = "Schlie<EFBFBD>e Dialog";
break;
/** Opening network connection. */
case JOB_OPENINGNETWORK:
msg = "Beginne Netzwerkverbindung";
break;
/** Closing network connection. */
case JOB_CLOSINGNETWORK:
msg = "Schlie<EFBFBD>e Netzwerkverbindung";
break;
/** Get balance */
case JOB_GET_BALANCE:
msg = "Job: Saldo abholen";
break;
/** Get transaction statement */
case JOB_GET_TRANS:
msg = "Job: Ums<6D>tze abholen";
break;
/** Transfer money */
case JOB_NEW_TRANSFER:
msg = "Job: Neue <20>berweisung";
break;
/** Debit note */
case JOB_DEBIT_NOTE:
msg = "";
break;
/** Get standing orders */
case JOB_GET_STO:
msg = "";
break;
/** Create a new standing order */
case JOB_NEW_STO:
msg = "";
break;
/** Delete a standing order */
case JOB_DELETE_STO:
msg = "";
break;
/** Get account list */
case JOB_GET_ACCOUNTS:
msg = "Job: Kontenliste abholen";
break;
/** Get SystemId */
case JOB_GET_SYSTEMID:
msg = "Job: System-Kennung abgleichen";
break;
/** Get keys */
case JOB_GET_KEYS:
msg = "Job: Schl<68>ssel holen";
break;
/** Send keys */
case JOB_SEND_KEYS:
msg = "Job: Schl<68>ssel senden";
break;
}
fprintf(stdout,"Jobstart (w/ %d actions): %s\n",actions, msg);
}
HBCI_ProgressMonitor *
gnc_hbci_new_pmonitor()
{
HBCI_ProgressMonitorCB *pmon;
pmon = HBCI_ProgressMonitorCB_new();
HBCI_ProgressMonitorCB_setJobStarted(pmon, &jobStarted);
return HBCI_ProgressMonitorCB_ProgressMonitor(pmon);
}

View File

@@ -0,0 +1,36 @@
/* hbci-interactor.h
Copyright 2002 by Christian Stimming <stimming@tuhh.de> */
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
* *
***************************************************************************/
#ifndef HBCI_INTERACTION_H
#define HBCI_INTERACTION_H
#include <openhbci/interactor.h>
#include <openhbci/progressmonitor.h>
HBCI_Interactor *
gnc_hbci_new_interactor(void);
HBCI_ProgressMonitor *
gnc_hbci_new_pmonitor(void);
#endif