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

* src/import-export/hbci/gnc-hbci-utils.[hc]: Added hbci functions
	that are to be used from the rest of the gnucash UI.

	* src/import-export/hbci/*: More work on HBCI support (HBCI data
	is now actually stored in book's and account's kvp frames).

	* src/import-export/gnc-generic-import.h: Clarified docs.

	* src/engine/kvp_frame.h: Clarified doc about kvp_value_get_string
	(which is in fact non-copying.)


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7140 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2002-08-06 00:05:37 +00:00
parent be9a9ec846
commit 5667e7845c
15 changed files with 1010 additions and 290 deletions

View File

@@ -1,3 +1,16 @@
2002-08-06 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/gnc-hbci-utils.[hc]: Added hbci functions
that are to be used from the rest of the gnucash UI.
* src/import-export/hbci/*: More work on HBCI support (HBCI data
is now actually stored in book's and account's kvp frames).
* src/import-export/gnc-generic-import.h: Clarified docs.
* src/engine/kvp_frame.h: Clarified doc about kvp_value_get_string
(which is in fact non-copying.)
2002-08-05 Joshua Sled <jsled@asynchronous.org>
* src/gnome/dialog-sxsincelast.c (to_create_next): Fix for

View File

@@ -171,7 +171,13 @@ kvp_value * kvp_value_new_binary_nc(void * data, guint64 datasize);
kvp_value * kvp_value_new_glist_nc(GList *lst);
kvp_value * kvp_value_new_frame_nc(kvp_frame * value);
/* value accessors (NON-copying for frames/lists/guids/binary) */
/* Value accessors. Those for GUID, binary, GList, kvp_frame and
string are non-copying -- the caller can modify the value directly.
Note that the above non-copying list did not include the
get_string() function. But in fact that function has always been a
non-copying one -- therefore don't free the result unless you want
to delete the whole kvp_frame by yourself. */
kvp_value_t kvp_value_get_type(const kvp_value * value);
gint64 kvp_value_get_gint64(const kvp_value * value);

View File

@@ -29,13 +29,40 @@
#include "Account.h"
/* The gnc_import_select_account():
Must be called with a string containing a unique identifier for the account. If an account with a matching online_id kvp_frame is found, the function immediately returns with a pointer to that account. Otherwise, the user is prompted to select a GnuCash account or create a new one (in both cases, the unique identifier is written to the account's kvp_frame, so the user won't be prompted again. If the user refuses to select or create an account
Params:
account_online_id_value: MANDATORY: The string containing your account_id
gchar * account_human_description: OPTIONNAL: A human-readable description of the account. If not NULL, it will be shown before the id in the account matching dialog. It will also be used as the default account name if a new account is created.
gnc_commodity * new_account_default_currenc: OPTIONNAL: If not NULL, it will be the account's commodity if a new account is created. If not NULL, the function will also warn the user if the found or created account's commodity doesn't match.
GNCAccountType new_account_default_type: OPTIONNAL: If not NO_TYPE, it will be the account's type if a new account is created. If not NO_TYPE, the function will also warn the user if the found or created account's commodity doesn't match.
Return: A pointer to the found or created Account, or NULL if no account was found or created.
Must be called with a string containing a unique identifier for the
account. If an account with a matching online_id kvp_frame is
found, the function immediately returns with a pointer to that
account. Otherwise, the user is prompted to select a GnuCash
account or create a new one (in both cases, the unique identifier is
written to the account's kvp_frame, so the user won't be prompted
again). If the user refuses to select or create an account, NULL is
returned.
Params:
account_online_id_value: The string containing your account_id
gchar * account_human_description: A human-readable description of
the account. Can be NULL. If it is not NULL, it will be shown before
the id in the account matching dialog. It will also be used as
the default account name if a new account is created.
gnc_commodity * new_account_default_currenc: Default commodity of
the new account. Can be NULL. If not NULL, it will be the
account's commodity if a new account is created. Also, if not
NULL, the function will also warn the user if the found or created
account's commodity doesn't match.
GNCAccountType new_account_default_type: Default account type of a
new account. Can be NULL. If not NO_TYPE, it will be the
account's type if a new account is created. If not NO_TYPE, the
function will also warn the user if the found or created account's
commodity doesn't match.
Return: A pointer to the found or created Account, or NULL if no
account was found or created.
*/
Account * gnc_import_select_account(char * account_online_id_value,
char * account_human_description,

View File

@@ -6,7 +6,9 @@ libgncmod_hbci_la_SOURCES = \
gncmod-hbci.c \
druid-hbci-initial.c \
druid-hbci-final.c \
gnc-hbci-kvp.c
gnc-hbci-kvp.c \
hbci-account-picker.c \
gnc-hbci-utils.c
noinst_HEADERS =

View File

@@ -28,9 +28,15 @@
#include <unistd.h>
#include "druid-hbci-initial.h"
/* #include "Group.h" */
#include "gnc-hbci-kvp.h"
#include "hbci-account-picker.h"
#include "gnc-hbci-utils.h"
#include "dialog-utils.h"
#include "druid-utils.h"
#include "gnc-ui-util.h"
#include "gnc-ui.h"
/* #include "Group.h" */
/* #include "glade/glade-xml.h" */
/* #include "gnc-amount-edit.h" */
/* #include "gnc-commodity-edit.h" */
@@ -38,21 +44,24 @@
/* #include "gnc-component-manager.h" */
/* #include "../gnome-utils/gnc-dir.h" */
/* #include "gnc-gui-query.h" */
/* #include "gnc-ui-util.h" */
/* #include "io-example-account.h" */
/* #include "top-level.h" */
#include <openhbci/api.h>
typedef struct
struct _hbciinitialinfo
{
GtkWidget *window;
GtkWidget *druid;
/* configfile page */
GtkWidget *filepage;
GtkWidget *configfileentry;
/* bank info page */
GtkWidget *bankcode;
GtkWidget *countrycode;
GtkWidget *ipaddr;
GtkWidget *port;
//GtkWidget *port;
/* user info page */
GtkWidget *userid;
@@ -69,12 +78,35 @@ typedef struct
/* iniletter user */
GtkWidget *user_text;
/* account match page */
GtkWidget *accountpage;
GtkWidget *accountlist;
/* OpenHBCI stuff */
HBCI_API *api;
} HBCIInitialInfo;
//static AccountGroup *our_final_group = NULL;
/* account match: row_number (int) -> hbci_account */
GHashTable *hbci_hash;
/* hbci_account (direct) -> gnucash_account -- DO NOT DELETE THE KEYS! */
GHashTable *gnc_hash;
};
static gboolean
hash_remove (gpointer key, gpointer value, gpointer user_data)
{
free (key);
return TRUE;
}
static void
delete_hash (GHashTable *hash)
{
if (hash != NULL) {
g_hash_table_foreach_remove (hash, &hash_remove, NULL);
g_hash_table_destroy (hash);
}
}
static void
delete_initial_druid (HBCIInitialInfo *info)
@@ -85,11 +117,44 @@ delete_initial_druid (HBCIInitialInfo *info)
gtk_widget_destroy (info->window);
info->window = NULL;
if (info->api == NULL) return;
HBCI_API_delete(info->api);
info->api = NULL;
if (info->api != NULL) {
HBCI_API_delete(info->api);
info->api = NULL;
}
delete_hash (info->hbci_hash);
info->hbci_hash = NULL;
g_hash_table_destroy (info->gnc_hash);
info->gnc_hash = NULL;
}
static void
account_GHFunc (gpointer key, gpointer value, gpointer user_data)
{
HBCI_Account *hbci_acc = key;
Account *gnc_acc = value;
g_assert(hbci_acc);
g_assert(gnc_acc);
gnc_hbci_set_account_accountid
(gnc_acc, HBCI_Account_accountId (hbci_acc));
gnc_hbci_set_account_bankcode
(gnc_acc, HBCI_Bank_bankCode(HBCI_Account_bank(hbci_acc)));
gnc_hbci_set_account_countrycode
(gnc_acc, HBCI_Bank_countryCode(HBCI_Account_bank(hbci_acc)));
}
/* hash is a DIRECT hash from each HBCI account to each gnucash
account. */
static void
accounts_save_kvp (GHashTable *hash)
{
g_assert(hash);
g_hash_table_foreach (hash, &account_GHFunc, NULL);
}
static void
on_cancel (GnomeDruid *gnomedruid,
gpointer user_data)
@@ -106,9 +171,107 @@ on_finish (GnomeDruidPage *gnomedruidpage,
{
HBCIInitialInfo *info = user_data;
accounts_save_kvp (info->gnc_hash);
delete_initial_druid(info);
}
static int
count_accounts (const list_HBCI_Bank *banklist)
{
list_HBCI_Bank_iter *iter, *iterend;
int accounts;
iter = list_HBCI_Bank_begin (banklist);
iterend = list_HBCI_Bank_end (banklist);
accounts = 0;
for ( ; ! list_HBCI_Bank_iter_equal(iter, iterend) ;
list_HBCI_Bank_iter_next (iter)) {
accounts +=
list_HBCI_Account_size
(HBCI_Bank_accounts (list_HBCI_Bank_iter_get (iter)));
}
list_HBCI_Bank_iter_delete (iter);
list_HBCI_Bank_iter_delete (iterend);
return accounts;
}
static gboolean
on_configfile_next (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
char *filename;
HBCI_API *api;
gboolean createnew;
filename = g_strstrip(gnome_file_entry_get_full_path
(GNOME_FILE_ENTRY (info->configfileentry), FALSE));
if (!g_file_test (filename, G_FILE_TEST_ISFILE | G_FILE_TEST_ISLINK)) {
createnew = gnc_verify_dialog_parented
(GTK_WIDGET (info->window),
TRUE,
_("The file %s does not exist. \nWould you like to create it now?\n (not yet implemented)"),
filename ? filename : _("(null"));
if (!createnew) {
free (filename);
return TRUE;
}
// FIXME: create file here
}
if (!g_file_test (filename, G_FILE_TEST_ISFILE | G_FILE_TEST_ISLINK)) {
gnc_error_dialog_parented
(GTK_WINDOW (info->window),
_("The file %s does not exist."),
filename ? filename : _("(null"));
free (filename);
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;
}
api = gnc_hbci_api_new (filename);
free (filename);
info->api = api;
/* Get HBCI bank and account list */
{
const list_HBCI_Bank *banklist;
int accounts;
banklist = HBCI_API_bankList (api);
//printf("%d banks found.\n", list_HBCI_Bank_size (banklist));
if (list_HBCI_Bank_size (banklist) == 0) {
return FALSE;
}
accounts = count_accounts(banklist);
//printf("%d accounts found.\n", accounts);
if (accounts > 0){
gnome_druid_set_page (GNOME_DRUID (info->druid),
GNOME_DRUID_PAGE (info->accountpage));
return TRUE;
}
}
return FALSE;
}
static gboolean
on_userid_next (GnomeDruidPage *gnomedruidpage,
@@ -116,38 +279,24 @@ on_userid_next (GnomeDruidPage *gnomedruidpage,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
const char *bankcode;
int countrycode;
const char *ipaddr, *port;
const char *userid;
HBCI_API *api;
HBCI_Error *err;
const char *cfgfile = HBCI_CFGFILE;
char *errstring;
HBCI_Bank *bank;
HBCI_User *user;
const char *bankcode = NULL;
int countrycode = 0;
const char *ipaddr = NULL;//, *port;
const char *userid = NULL;
HBCI_API *api = info->api;
HBCI_Bank *bank = NULL;
const HBCI_User *user = NULL;
bankcode = gtk_entry_get_text (GTK_ENTRY (info->bankcode));
countrycode = atoi (gtk_entry_get_text (GTK_ENTRY (info->countrycode)));
ipaddr = gtk_entry_get_text (GTK_ENTRY (info->ipaddr));
port = gtk_entry_get_text (GTK_ENTRY (info->port));
//port = gtk_entry_get_text (GTK_ENTRY (info->port));
userid = gtk_entry_get_text (GTK_ENTRY (info->userid));
printf("Got bankcode %s and userid %s.\n", bankcode, userid);
api = HBCI_API_new(FALSE, TRUE);
err = HBCI_API_loadEnvironment(api, cfgfile);
if (!HBCI_Error_isOk(err)) {
errstring = HBCI_Error_errorString(err);
fprintf(stderr,"At on_userid_next, loadEnvironment: ERROR: %s\n",
errstring);
free(errstring);
HBCI_API_delete(api);
info->api = NULL;
return FALSE;
}
//printf("Got bankcode %s and userid %s.\n", bankcode, userid);
bank = HBCI_API_findBank(api, countrycode, bankcode);
if (bank == NULL) {
printf("No bank found.\n");
@@ -180,7 +329,8 @@ on_medium_next (GnomeDruidPage *gnomedruidpage,
const char *mediumpath;
is_rdh = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (info->mediumrdh));
mediumpath = gtk_entry_get_text (GTK_ENTRY (info->mediumpath));
mediumpath = gnome_file_entry_get_full_path
(GNOME_FILE_ENTRY (info->mediumpath), FALSE);
return FALSE;
}
@@ -196,7 +346,6 @@ on_iniletter_server_next (GnomeDruidPage *gnomedruidpage,
gint *pos;
pos = g_new0(gint,1);
*pos = 0;
gtk_editable_insert_text (text, mytext, strlen(mytext), pos);
@@ -210,10 +359,189 @@ on_iniletter_user_next (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
//HBCIInitialInfo *info = user_data;
return FALSE;
}
/* Update the account list GtkCList widget */
static void
update_accountlist (HBCIInitialInfo *info)
{
const list_HBCI_Bank *banklist;
list_HBCI_Bank_iter *iter, *iterend;
gchar *row_text[3];
int row;
gint *row_key;
const HBCI_Account *hacc;
Account *gacc;
const list_HBCI_Account *acclist;
list_HBCI_Account_iter *aiter, *aiterend;
int sel_row = 0;
g_assert(info);
g_assert(info->api);
g_assert(info->gnc_hash);
banklist = HBCI_API_bankList (info->api);
//printf("%d banks found.\n", list_HBCI_Bank_size (banklist));
if (list_HBCI_Bank_size (banklist) == 0)
return;
/* Store old selected row here. */
sel_row = (GTK_CLIST(info->accountlist))->focus_row;
/* Delete old list */
gtk_clist_freeze (GTK_CLIST (info->accountlist));
gtk_clist_clear (GTK_CLIST (info->accountlist));
row_text[2] = "";
/* Delete old row_number -> hbci_account hash */
delete_hash (info->hbci_hash);
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 */
iter = list_HBCI_Bank_begin (banklist);
iterend = list_HBCI_Bank_end (banklist);
for ( ; ! list_HBCI_Bank_iter_equal(iter, iterend) ;
list_HBCI_Bank_iter_next (iter)) {
acclist = HBCI_Bank_accounts (list_HBCI_Bank_iter_get (iter));
if (list_HBCI_Account_size (acclist) > 0) {
/* Now go through all HBCI accounts of this HBCI bank */
aiter = list_HBCI_Account_begin (acclist);
aiterend = list_HBCI_Account_end (acclist);
for ( ; ! list_HBCI_Account_iter_equal(aiter, aiterend) ;
list_HBCI_Account_iter_next (aiter)) {
/* Now add this HBCI account to the CList widget */
hacc = list_HBCI_Account_iter_get(aiter);
/* Account code, then Bank name, then Bank code in parentheses. */
row_text[0] =
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)));
/* Get corresponding gnucash account */
gacc = g_hash_table_lookup (info->gnc_hash, hacc);
/* Build the text for the gnucash account. */
if (gacc == NULL)
row_text[1] = "";
else
row_text[1] =
xaccAccountGetFullName (gacc, gnc_get_account_separator ());
/* Add this row to the list */
row = gtk_clist_append (GTK_CLIST (info->accountlist), row_text);
/* Set the "new" checkbox. */
gnc_clist_set_check (GTK_CLIST (info->accountlist), row, 2,
FALSE);
/* 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);
}
list_HBCI_Account_iter_delete (aiter);
list_HBCI_Account_iter_delete (aiterend);
}
}
list_HBCI_Bank_iter_delete (iter);
list_HBCI_Bank_iter_delete (iterend);
//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));
g_hash_table_thaw (info->hbci_hash);
gtk_clist_thaw (GTK_CLIST (info->accountlist));
/* move to the old selected row */
(GTK_CLIST(info->accountlist))->focus_row = sel_row;
gtk_clist_moveto(GTK_CLIST(info->accountlist), sel_row, 0, 0.0, 0.0);
}
struct hbci_acc_cb_data
{
HBCI_API *api;
GHashTable *hash;
};
static gpointer
hbci_accountcallback (Account *gnc_acc, gpointer user_data)
{
struct hbci_acc_cb_data *data = user_data;
HBCI_Account *hbci_acc = NULL;
hbci_acc = (HBCI_Account *) gnc_hbci_get_hbci_acc (data->api, gnc_acc);
if (hbci_acc) {
g_hash_table_insert (data->hash, hbci_acc, gnc_acc);
}
return NULL;
}
static GHashTable *
gnc_hbci_new_hash_from_kvp (HBCI_API *api)
{
GHashTable *hash;
hash = g_hash_table_new (&g_direct_hash, &g_direct_equal);
if (api) {
struct hbci_acc_cb_data data;
AccountGroup *grp = gnc_book_get_group (gnc_get_current_book ());
data.api = api;
data.hash = hash;
xaccGroupForEachAccount (grp,
&hbci_accountcallback,
&data, TRUE);
}
return hash;
}
static void
on_accountlist_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
if (info->gnc_hash == NULL)
info->gnc_hash = gnc_hbci_new_hash_from_kvp (info->api);
update_accountlist(info);
}
static void
on_accountlist_select_row (GtkCList *clist, gint row,
gint column, GdkEvent *event,
gpointer user_data)
{
HBCIInitialInfo *info = user_data;
HBCI_Account *hbci_acc;
Account *gnc_acc, *old_value;
hbci_acc = g_hash_table_lookup (info->hbci_hash, &row);
if (hbci_acc) {
old_value = g_hash_table_lookup (info->gnc_hash, hbci_acc);
gnc_acc = hbci_account_picker_dialog(info, old_value);
if (gnc_acc) {
if (old_value)
g_hash_table_remove (info->gnc_hash, hbci_acc);
g_hash_table_insert (info->gnc_hash, hbci_acc, gnc_acc);
}
/* update display */
update_accountlist(info);
} /* hbci_acc */
}
void gnc_hbci_initial_druid (void)
{
@@ -235,11 +563,33 @@ 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 */
char *filename;
info->configfileentry =
glade_xml_get_widget(xml, "configfile_fileentry");
/* Set the saved filename, if that is a valid file */
filename =
g_strdup (gnc_hbci_get_book_configfile (gnc_get_current_book () ));
if (filename &&
g_file_test (filename, G_FILE_TEST_ISFILE | G_FILE_TEST_ISLINK))
gtk_entry_set_text
(GTK_ENTRY (gnome_file_entry_gtk_entry
(GNOME_FILE_ENTRY (info->configfileentry))),
filename);
free (filename);
page = glade_xml_get_widget(xml, "configfile_page");
info->filepage = page;
gtk_signal_connect (GTK_OBJECT (page), "next",
GTK_SIGNAL_FUNC (on_configfile_next), info);
}
{
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");
//info->port = glade_xml_get_widget(xml, "port_nr_entry");
}
{
info->userid = glade_xml_get_widget(xml, "user_id_entry");
@@ -250,7 +600,7 @@ void gnc_hbci_initial_druid (void)
}
{
info->mediumrdh = glade_xml_get_widget(xml, "rdh_radiobutton");
info->mediumpath = glade_xml_get_widget(xml, "path_entry");
info->mediumpath = glade_xml_get_widget(xml, "keyfile_fileentry");
info->mediumddv = glade_xml_get_widget(xml, "ddv_radiobutton");
page = glade_xml_get_widget(xml, "medium_page");
gtk_signal_connect (GTK_OBJECT (page), "next",
@@ -268,6 +618,16 @@ void gnc_hbci_initial_druid (void)
gtk_signal_connect (GTK_OBJECT (page), "next",
GTK_SIGNAL_FUNC (on_iniletter_user_next), info);
}
{
info->accountlist = glade_xml_get_widget(xml, "account_page_list");
gtk_signal_connect (GTK_OBJECT (info->accountlist), "select_row",
GTK_SIGNAL_FUNC (on_accountlist_select_row), info);
page = glade_xml_get_widget(xml, "account_match_page");
info->accountpage = page;
gtk_signal_connect (GTK_OBJECT (page), "prepare",
GTK_SIGNAL_FUNC (on_accountlist_prepare), info);
}
//gtk_signal_connect (GTK_OBJECT(dialog), "destroy",

View File

@@ -28,4 +28,7 @@
void gnc_hbci_initial_druid (void);
SCM scm_hbci_initial_druid (void);
typedef struct _hbciinitialinfo HBCIInitialInfo;
#endif

View File

@@ -50,17 +50,17 @@ Click '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>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
</widget>
<widget>
<class>GnomeDruidPageStandard</class>
<name>config_file_page</name>
<name>configfile_page</name>
<title>Enter OpenHBCI Configuration File</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
@@ -80,7 +80,7 @@ HBCI connection now.</text>
<class>GtkFrame</class>
<name>frame56</name>
<label>OpenHBCI Configuration File</label>
<label_xalign>0</label_xalign>
<label_xalign>4.84288e-08</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
@@ -93,7 +93,7 @@ HBCI connection now.</text>
<name>hbox108</name>
<border_width>10</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<spacing>5</spacing>
<widget>
<class>GtkLabel</class>
@@ -113,102 +113,28 @@ HBCI connection now.</text>
</widget>
<widget>
<class>GtkEntry</class>
<name>user_id_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>50</text_max_length>
<text></text>
<class>GnomeFileEntry</class>
<name>configfile_fileentry</name>
<max_saved>10</max_saved>
<title>Choose OpenHBCI Configuration File</title>
<directory>False</directory>
<modal>False</modal>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
<fill>True</fill>
</child>
</widget>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GnomeDruidPageStandard</class>
<name>config_page</name>
<title>Enter Config Information</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDruidPageStandard:vbox</child_name>
<name>vbox132</name>
<border_width>10</border_width>
<homogeneous>False</homogeneous>
<spacing>5</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkFrame</class>
<name>frame56</name>
<label>User Identification</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox108</name>
<border_width>10</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkLabel</class>
<name>label8477402</name>
<label>User ID</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>GtkEntry</class>
<name>config_file_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>50</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>Placeholder</class>
<widget>
<class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name>
<name>configfile-entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
</widget>
</widget>
@@ -220,7 +146,7 @@ HBCI connection now.</text>
<name>bank_page</name>
<title>Enter Bank Information</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
@@ -376,7 +302,7 @@ HBCI connection now.</text>
<class>GtkTable</class>
<name>table2</name>
<border_width>10</border_width>
<rows>2</rows>
<rows>1</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
@@ -408,32 +334,6 @@ HBCI connection now.</text>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477401</name>
<label>Port</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</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>GtkEntry</class>
<name>ip_address_entry</name>
@@ -457,30 +357,6 @@ HBCI connection now.</text>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>port_nr_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>5</text_max_length>
<text>3000</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>
</widget>
</widget>
@@ -491,7 +367,7 @@ HBCI connection now.</text>
<name>user_page</name>
<title>Enter User Information</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
@@ -571,14 +447,14 @@ HBCI connection now.</text>
<name>medium_page</name>
<title>Enter Security Medium Information</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDruidPageStandard:vbox</child_name>
<name>vbox134</name>
<border_width>5</border_width>
<border_width>10</border_width>
<homogeneous>False</homogeneous>
<spacing>10</spacing>
<child>
@@ -595,8 +471,8 @@ HBCI connection now.</text>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
@@ -621,25 +497,81 @@ HBCI connection now.</text>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox109</name>
<class>GtkVBox</class>
<name>vbox140</name>
<border_width>20</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox109</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label36251</name>
<label>Path to Key File</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GnomeFileEntry</class>
<name>keyfile_fileentry</name>
<history_id>keyfile</history_id>
<max_saved>10</max_saved>
<title>Choose file for secret key</title>
<directory>False</directory>
<modal>False</modal>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name>
<name>combo-entry1</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>/floppy/</text>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label36251</name>
<label>Path to Key File</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<name>label8477407</name>
<label>If you already have a key file, please choose it here.
If you do not have one yet, choose a filename, and a key file will be created there.</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xalign>4.47035e-08</xalign>
<yalign>1</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
@@ -648,21 +580,6 @@ HBCI connection now.</text>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>path_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>100</text_max_length>
<text>/floppy/</text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
@@ -685,26 +602,6 @@ HBCI connection now.</text>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label8477403</name>
<label>Once you have created the Security Medium, Gnucash will contact the HBCI server to ask for its keys (Initialization Letter from Server). After that, you have to verify these keys against the Ini-Letter your bank gave to you.
If you confirm the Ini-Letter to be correct, Gnucash will send your new keys to the server and will ask you to print out your personal Ini-Letter, which you will have to sign and send to your bank.</label>
<justify>GTK_JUSTIFY_FILL</justify>
<wrap>True</wrap>
<xalign>0.05</xalign>
<yalign>0.05</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
<pack>GTK_PACK_END</pack>
</child>
</widget>
</widget>
</widget>
@@ -713,7 +610,7 @@ If you confirm the Ini-Letter to be correct, Gnucash will send your new keys to
<name>iniletter_server_page</name>
<title>Verify Ini-Letter from Server</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
@@ -788,7 +685,7 @@ press 'Cancel', and contact your bank.</label>
<name>iniletter_user_page</name>
<title>Print Ini-Letter of User</title>
<title_color>255,255,255</title_color>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<widget>
@@ -858,25 +755,7 @@ Then press 'Next'.</label>
<widget>
<class>GnomeDruidPageStandard</class>
<name>account_match_page</name>
<signal>
<name>prepare</name>
<handler>gnc_ui_qif_import_accounts_prepare_cb</handler>
<data>QIF_Import_Druid</data>
<last_modification_time>Thu, 31 Aug 2000 14:19:54 GMT</last_modification_time>
</signal>
<signal>
<name>next</name>
<handler>gnc_ui_qif_import_generic_next_cb</handler>
<data>QIF_Import_Druid</data>
<last_modification_time>Tue, 06 Feb 2001 17:09:25 GMT</last_modification_time>
</signal>
<signal>
<name>back</name>
<handler>gnc_ui_qif_import_generic_back_cb</handler>
<data>QIF_Import_Druid</data>
<last_modification_time>Tue, 06 Feb 2001 17:09:37 GMT</last_modification_time>
</signal>
<title>Match QIF accounts with GnuCash accounts</title>
<title>Match HBCI accounts with GnuCash accounts</title>
<title_color>255,255,255</title_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
@@ -911,12 +790,6 @@ Then press 'Next'.</label>
<class>GtkCList</class>
<name>account_page_list</name>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>gnc_ui_qif_import_account_line_select_cb</handler>
<data>QIF_Import_Druid</data>
<last_modification_time>Thu, 07 Sep 2000 22:35:06 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>281,242,53</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@@ -927,7 +800,7 @@ Then press 'Next'.</label>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label834</name>
<label>QIF account name</label>
<label>HBCI account name</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -967,7 +840,7 @@ Then press 'Next'.</label>
<widget>
<class>GtkLabel</class>
<name>label828</name>
<label>Click &quot;Next&quot; to check matchings for QIF categories. </label>
<label>Click &quot;Next&quot; when all desired accounts are matching.</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -1001,7 +874,7 @@ have to execute the &quot;Finish HBCI Setup&quot; druid in order to use
the HBCI functionality.
Press 'Finish' now.</text>
<background_color>25,25,112</background_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
<text_color>0,0,0</text_color>

View File

@@ -29,13 +29,13 @@
#define HBCI_CONFIGFILE "config-filename"
/* Account */
gchar *gnc_hbci_get_account_accountid (Account *a)
char *gnc_hbci_get_account_accountid (Account *a)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNT_ID);
return kvp_value_get_string (value);
}
gchar *gnc_hbci_get_account_bankcode (Account *a)
char *gnc_hbci_get_account_bankcode (Account *a)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_frame_get_slot (frame, HBCI_BANK_CODE);
@@ -51,24 +51,30 @@ void gnc_hbci_set_account_accountid (Account *a, const char *id)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_value_new_string (id);
kvp_frame_set_slot (frame, HBCI_ACCOUNT_ID, value);
xaccAccountBeginEdit(a);
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_ID, value);
xaccAccountCommitEdit (a);
}
void gnc_hbci_set_account_bankcode (Account *a, const char *code)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_value_new_string (code);
kvp_frame_set_slot (frame, HBCI_BANK_CODE, value);
xaccAccountBeginEdit (a);
kvp_frame_set_slot_nc (frame, HBCI_BANK_CODE, value);
xaccAccountCommitEdit (a);
}
void gnc_hbci_set_account_countrycode (Account *a, gint code)
{
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
kvp_value *value = kvp_value_new_gint64 (code);
kvp_frame_set_slot (frame, HBCI_COUNTRY_CODE, value);
xaccAccountBeginEdit (a);
kvp_frame_set_slot_nc (frame, HBCI_COUNTRY_CODE, value);
xaccAccountCommitEdit (a);
}
/* GNCBook */
gchar *gnc_hbci_get_book_configfile (GNCBook *b)
char *gnc_hbci_get_book_configfile (GNCBook *b)
{
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
kvp_value *value = kvp_frame_get_slot (frame, HBCI_CONFIGFILE);
@@ -78,7 +84,8 @@ void gnc_hbci_set_book_configfile (GNCBook *b, const char *filename)
{
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
kvp_value *value = kvp_value_new_string (filename);
kvp_frame_set_slot (frame, HBCI_CONFIGFILE, value);
kvp_frame_set_slot_nc (frame, HBCI_CONFIGFILE, value);
gnc_book_kvp_changed (b);
}
/* lowlevel */

View File

@@ -30,17 +30,17 @@
#include "gnc-book.h"
/* Account */
gchar *gnc_hbci_get_account_accountid (Account *a);
char *gnc_hbci_get_account_accountid (Account *a);
void gnc_hbci_set_account_accountid (Account *a, const char *id);
gchar *gnc_hbci_get_account_bankcode (Account *a);
char *gnc_hbci_get_account_bankcode (Account *a);
void gnc_hbci_set_account_bankcode (Account *a, const char *code);
gint gnc_hbci_get_account_countrycode (Account *a);
void gnc_hbci_set_account_countrycode (Account *a, gint code);
/* GNCBook */
gchar *gnc_hbci_get_book_configfile (GNCBook *b);
char *gnc_hbci_get_book_configfile (GNCBook *b);
void gnc_hbci_set_book_configfile (GNCBook *b, const char *filename);
/* lowlevel */

View File

@@ -0,0 +1,95 @@
/********************************************************************\
* gnc-hbci-utils.c -- hbci utility functions *
* 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 "gnc-hbci-utils.h"
#include <gnome.h>
#include <openhbci/error.h>
#include "gnc-ui.h"
#include "gnc-hbci-kvp.h"
HBCI_API *
gnc_hbci_api_new (const char *filename)
{
HBCI_API *api = NULL;
HBCI_Error *err = NULL;
char *errstring;
if (!filename ||
!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)) {
errstring = HBCI_Error_errorString (err);
HBCI_Error_delete (err);
gnc_error_dialog
(_("Error while loading OpenHBCI config file:\n %s\n"), errstring);
free (errstring);
HBCI_API_delete (api);
return NULL;
}
HBCI_Error_delete (err);
return api;
}
HBCI_API *
gnc_hbci_api_new_currentbook ()
{
return gnc_hbci_api_new
(gnc_hbci_get_book_configfile (gnc_get_current_book ()));
}
const 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;
bankcode = gnc_hbci_get_account_bankcode (gnc_acc);
countrycode = gnc_hbci_get_account_countrycode (gnc_acc);
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);
if (bank) {
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 */
return NULL;
}

View File

@@ -0,0 +1,53 @@
/********************************************************************\
* gnc-hbci-utils.h -- hbci utility functions *
* 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 GNC_HBCI_UTILS_H
#define GNC_HBCI_UTILS_H
#include <glib.h>
#include <openhbci/account.h>
#include <openhbci/api.h>
#include "Account.h"
#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);
/* Same as above, but takes the filename already from the current
book's kvp frame. */
HBCI_API * gnc_hbci_api_new_currentbook ();
/* 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. */
const HBCI_Account *
gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc);
#endif

View File

@@ -69,7 +69,7 @@ gnc_module_init(int refcount)
gh_new_procedure("gnc:hbci-initial-setup",
scm_hbci_initial_druid, 0, 0, 0);
gh_new_procedure("gnc:hbci-finish-setup",
scm_hbci_final_druid, 0, 0, 0);
scm_hbci_final_druid, 0, 0, 0);
//printf("Been in gncmod-hbci.c.\n");

View File

@@ -0,0 +1,245 @@
/********************************************************************\
* hbci-account-picker.c -- window for picking a Gnucash account *
* Copyright (C) 2002 Christian <stimming@tuhh.de> *
* Heavily copied from the QIF importer, which is *
* Copyright (C) 2000-2001 Bill Gribble <grib@billgribble.com> *
* *
* 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 <stdio.h>
#include <guile/gh.h>
#include "hbci-account-picker.h"
#include "dialog-utils.h"
#include "druid-hbci-initial.h"
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "Group.h"
struct _accountpickerdialog {
GtkWidget * dialog;
GtkWidget * treeview;
HBCIInitialInfo * hbci_info;
Account * select;
GHashTable *hash;
};
static void
acct_tree_add_accts(AccountGroup *accts,
GtkCTree * tree, GtkCTreeNode * parent,
char * base_name, int *row,
HBCIAccountPickerDialog *wind) {
char * acctinfo[2];
char * acctname;
char sep[2] = " ";
GtkCTreeNode * node;
gboolean leafnode;
AccountList *current;
AccountList *list, *lastlist;
AccountGroup *children;
sep[0] = gnc_get_account_separator();
acctinfo[1] = "";
list = xaccGroupGetAccountList (accts);
current = g_list_first (list);
lastlist = g_list_last (list);
while(current && (current != lastlist)) {
acctname = g_strdup (xaccAccountGetName (current->data));
acctinfo[0] = acctname;
children = xaccAccountGetChildren (current->data);
leafnode = (children) ? FALSE : TRUE;
node = gtk_ctree_insert_node(tree, parent, NULL,
acctinfo, 2,
NULL, NULL, NULL, NULL,
leafnode, TRUE);
/* set some row data */
gtk_ctree_node_set_row_data(tree, node, current->data);
g_hash_table_insert (wind->hash, node, current->data);
gnc_clist_set_check (GTK_CLIST (tree), (*row)++, 1,
FALSE);
if(!leafnode) {
acct_tree_add_accts(children, tree, node, acctname, row, wind);
}
current = g_list_next (current);
}
}
static void
build_acct_tree(HBCIAccountPickerDialog * picker, HBCIInitialInfo * import) {
GtkCTreeNode * new_sel;
int row = 0;
AccountGroup *acct_tree;
acct_tree = gnc_book_get_group (gnc_get_current_book ());
gtk_clist_freeze (GTK_CLIST(picker->treeview));
gtk_clist_clear(GTK_CLIST(picker->treeview));
gtk_clist_set_column_justification (GTK_CLIST(picker->treeview),
1, GTK_JUSTIFY_CENTER);
acct_tree_add_accts(acct_tree, GTK_CTREE(picker->treeview),
NULL, NULL, &row, picker);
if(picker->select) {
new_sel =
gtk_ctree_find_by_row_data(GTK_CTREE(picker->treeview),
NULL,
picker->select);
gtk_ctree_select(GTK_CTREE(picker->treeview), new_sel);
gtk_ctree_node_moveto(GTK_CTREE(picker->treeview), new_sel, 0,
0.5, 0.0);
}
gtk_clist_columns_autosize (GTK_CLIST (picker->treeview));
gtk_clist_column_titles_passive (GTK_CLIST (picker->treeview));
gtk_clist_thaw (GTK_CLIST(picker->treeview));
}
/* static void */
/* new_child_string_cb(char * string, gpointer data) { */
/* if(string) { */
/* strncpy(data, string, 250); */
/* } */
/* else { */
/* *(char *)data = 0; */
/* } */
/* } */
/* static void */
/* gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data) { */
/* HBCIAccountPickerDialog * wind = user_data; */
/* //SCM name_setter = gh_eval_str("qif-map-entry:set-gnc-name!"); */
/* char name[251] = ""; */
/* char sep[2] = " "; */
/* int retval = -1; */
/* char * fullname = NULL; */
/* GtkWidget * dlg = gnome_request_dialog(FALSE, */
/* _("Enter a name for the account"), */
/* "", 250, */
/* &new_child_string_cb, &name[0], */
/* NULL); */
/* retval = gnome_dialog_run_and_close(GNOME_DIALOG(dlg)); */
/* sep[0] = gnc_get_account_separator(); */
/* retval is 0 if the 'ok' button was clicked */
/* if(retval == 0) { */
/* if(wind->select) { */
/* fullname = g_strjoin(sep, xaccAccountGetName(wind->select), name, NULL); */
/* } */
/* else { */
/* fullname = g_strdup(name); */
/* } */
/* //wind->selected_name = g_strdup(fullname); */
/* //gh_call2(name_setter, wind->select, gh_str02scm(fullname)); */
/* //g_free(fullname); */
/* } */
/* build_acct_tree(wind, wind->hbci_info); */
/* } */
static void
gnc_ui_qif_account_picker_select_cb(GtkCTree * tree,
GtkCTreeNode * node,
gint column,
gpointer user_data) {
HBCIAccountPickerDialog * wind = user_data;
wind->select =
g_hash_table_lookup (wind->hash, node);
}
static void
gnc_ui_qif_account_picker_unselect_cb(GtkCTree * tree,
GtkCTreeNode * node,
gint column,
gpointer user_data) {
HBCIAccountPickerDialog * wind = user_data;
wind->select = NULL;
}
/****************************************************************
* hbci_account_picker_dialog
* select an account from the ones that the engine knows about.
* it returns a pointer to the resulting account or
* NULL on cancel. It's modal.
****************************************************************/
Account *
hbci_account_picker_dialog(HBCIInitialInfo *info, Account *initial_sel) {
HBCIAccountPickerDialog * wind;
int retval = -1;
Account *retaccount;
//char * scmname;
GladeXML *xml;
wind = g_new0(HBCIAccountPickerDialog, 1);
xml = gnc_glade_xml_new ("qif.glade", "QIF Import Account Picker");
//glade_xml_signal_connect_data
// (xml, "gnc_ui_qif_account_picker_new_cb",
// GTK_SIGNAL_FUNC (gnc_ui_qif_account_picker_new_cb), wind);
wind->dialog = glade_xml_get_widget (xml, "QIF Import Account Picker");
wind->treeview = glade_xml_get_widget (xml, "account_tree");
wind->hbci_info = info;
wind->select = initial_sel;
wind->hash = g_hash_table_new(&g_direct_hash, &g_direct_equal);
gtk_signal_connect(GTK_OBJECT(wind->treeview), "tree_select_row",
GTK_SIGNAL_FUNC(gnc_ui_qif_account_picker_select_cb),
wind);
gtk_signal_connect(GTK_OBJECT(wind->treeview), "tree_unselect_row",
GTK_SIGNAL_FUNC(gnc_ui_qif_account_picker_unselect_cb),
wind);
/* this is to get the checkmarks set up right.. it will get called
* again after the window is mapped. */
build_acct_tree(wind, wind->hbci_info);
retval = gnome_dialog_run_and_close(GNOME_DIALOG(wind->dialog));
retaccount = (retval == 0) ? wind->select : initial_sel;
g_hash_table_destroy (wind->hash);
g_free(wind);
return retaccount;
}

View File

@@ -0,0 +1,35 @@
/********************************************************************\
* hbci-account-picker.h -- window for picking a GNUcash account *
* (GnuCash) *
* Copyright (C) 2002 Christian <stimming@tuhh.de>
* *
* 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 HBCI_ACCOUNT_PICKER_H
#define HBCI_ACCOUNT_PICKER_H
#include "druid-hbci-initial.h"
#include "Account.h"
Account *hbci_account_picker_dialog(HBCIInitialInfo *info,
Account *initial_sel);
typedef struct _accountpickerdialog HBCIAccountPickerDialog;
#endif

View File

@@ -16,12 +16,13 @@
(list "_Tools" "HBCI" "")
(lambda ()
(gnc:hbci-initial-setup))))
(gnc:add-extension
(gnc:make-menu-item (N_ "Final HBCI Setup")
(N_ "Finish the HBCI Setup")
(list "_Tools" "HBCI" "")
(lambda ()
(gnc:hbci-finish-setup)))))
)
; (gnc:add-extension
; (gnc:make-menu-item (N_ "Final HBCI Setup")
; (N_ "Finish the HBCI Setup")
; (list "_Tools" "HBCI" "")
; (lambda ()
; (gnc:hbci-finish-setup)))))
(gnc:hook-add-dangler gnc:*ui-startup-hook* add-hbci-menu-items)