Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Oct 9, 2019
2 parents 58cfb58 + 662d29d commit 8403404
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 412 deletions.
16 changes: 8 additions & 8 deletions data/accounts/en_GB/uk-vat.gnucash-xea
Expand Up @@ -137,7 +137,7 @@
<act:parent type="new">9c566ece97799eda4e900b003ce48e48</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
<act:name>EC Reverse VAT Purchase</act:name>
<act:name>EU Reverse VAT Purchase</act:name>
<act:id type="new">6708e3ff1292c2b5defd07da9f858b60</act:id>
<act:type>ASSET</act:type>
<act:commodity>
Expand Down Expand Up @@ -273,7 +273,7 @@
<act:parent type="new">3352145930e40b21fee20532ad07501b</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
<act:name>EC</act:name>
<act:name>EU</act:name>
<act:id type="new">37d726ec68d451d098496b7f5513f6f8</act:id>
<act:type>LIABILITY</act:type>
<act:commodity>
Expand All @@ -293,7 +293,7 @@
<cmdty:id>GBP</cmdty:id>
</act:commodity>
<act:commodity-scu>100</act:commodity-scu>
<act:description>All, including zero rate UK/EC and World (Box 1)</act:description>
<act:description>All, including zero rate UK/EU and World (Box 1)</act:description>
<act:parent type="new">a46d9e9624070fcd2427973a4c725ed6</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
Expand Down Expand Up @@ -483,15 +483,15 @@
<act:parent type="new">86ef7451027dcb6223bb01204ac09a5e</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
<act:name>EEC</act:name>
<act:name>EU</act:name>
<act:id type="new">af74692df15b1de7665d5dd7a197cdfb</act:id>
<act:type>INCOME</act:type>
<act:commodity>
<cmdty:space>ISO4217</cmdty:space>
<cmdty:id>GBP</cmdty:id>
</act:commodity>
<act:commodity-scu>100</act:commodity-scu>
<act:description>Sales in EEC</act:description>
<act:description>Sales in EU</act:description>
<act:slots>
<slot>
<slot:key>placeholder</slot:key>
Expand All @@ -509,7 +509,7 @@
<cmdty:id>GBP</cmdty:id>
</act:commodity>
<act:commodity-scu>100</act:commodity-scu>
<act:description>Sale of goods within EEC</act:description>
<act:description>Sale of goods within EU</act:description>
<act:parent type="new">af74692df15b1de7665d5dd7a197cdfb</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
Expand All @@ -521,7 +521,7 @@
<cmdty:id>GBP</cmdty:id>
</act:commodity>
<act:commodity-scu>100</act:commodity-scu>
<act:description>Sale of services within EEC</act:description>
<act:description>Sale of services within EU</act:description>
<act:slots>
<slot>
<slot:key>notes</slot:key>
Expand Down Expand Up @@ -726,7 +726,7 @@
<act:parent type="new">d77071fafc0de8455dd566b805bfcc40</act:parent>
</gnc:account>
<gnc:account version="2.0.0">
<act:name>EEC Reverse VAT</act:name>
<act:name>EU Reverse VAT</act:name>
<act:id type="new">af9b5ef4814015a83053a4c991ca0c1a</act:id>
<act:type>EXPENSE</act:type>
<act:commodity>
Expand Down
18 changes: 17 additions & 1 deletion gnucash/import-export/aqb/dialog-ab.glade
Expand Up @@ -664,6 +664,22 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="optical_challenge">
<property name="name">optical_challenge</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
Expand Down Expand Up @@ -751,7 +767,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">3</property>
</packing>
</child>
</object>
Expand Down
102 changes: 100 additions & 2 deletions gnucash/import-export/aqb/gnc-gwen-gui.c
Expand Up @@ -170,9 +170,16 @@ static gboolean keep_alive(GncGWENGui *gui);
static void cm_close_handler(gpointer user_data);
static void erase_password(gchar *password);
static gchar *strip_html(gchar *text);
#ifndef AQBANKING6
static void get_input(GncGWENGui *gui, guint32 flags, const gchar *title,
const gchar *text, gchar **input, gint min_len,
gint max_len);
#else
static void get_input(GncGWENGui *gui, guint32 flags, const gchar *title,
const gchar *text, const char *mimeType,
const char *pChallenge, uint32_t lChallenge,
gchar **input, gint min_len, gint max_len);
#endif
static gint messagebox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
const gchar *text, const gchar *b1, const gchar *b2,
const gchar *b3, guint32 guiid);
Expand All @@ -190,7 +197,7 @@ static gint progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id,
static gint progress_log_cb(GWEN_GUI *gwen_gui, guint32 id,
GWEN_LOGGER_LEVEL level, const gchar *text);
static gint progress_end_cb(GWEN_GUI *gwen_gui, guint32 id);
#ifndef GWENHYWFAR5
#ifndef AQBANKING6
static gint GNC_GWENHYWFAR_CB getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags,
const gchar *token,
const gchar *title,
Expand Down Expand Up @@ -977,8 +984,15 @@ strip_html(gchar *text)
}

static void
#ifndef AQBANKING6
get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
gchar **input, gint min_len, gint max_len)
#else
get_input(GncGWENGui *gui, guint32 flags, const gchar *title,
const gchar *text, const char *mimeType,
const char *pChallenge, uint32_t lChallenge,
gchar **input, gint min_len, gint max_len)
#endif
{
GtkBuilder *builder;
GtkWidget *dialog;
Expand All @@ -987,6 +1001,7 @@ get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
GtkWidget *confirm_entry;
GtkWidget *confirm_label;
GtkWidget *remember_pin_checkbutton;
GtkImage *optical_challenge;
const gchar *internal_input, *internal_confirmed;
gboolean confirm = (flags & GWEN_GUI_INPUT_FLAGS_CONFIRM) != 0;
gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;
Expand All @@ -1006,6 +1021,14 @@ get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
confirm_entry = GTK_WIDGET(gtk_builder_get_object (builder, "confirm_entry"));
confirm_label = GTK_WIDGET(gtk_builder_get_object (builder, "confirm_label"));
remember_pin_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "remember_pin"));
optical_challenge = GTK_IMAGE(gtk_builder_get_object (builder, "optical_challenge"));
gtk_widget_set_visible(GTK_WIDGET(optical_challenge), FALSE);
#ifdef AQBANKING6
if(mimeType != NULL && pChallenge != NULL && lChallenge > 0)
{
gtk_widget_set_visible(GTK_WIDGET(optical_challenge), TRUE);
}
#endif
if (is_tan)
{
gtk_widget_hide(remember_pin_checkbutton);
Expand Down Expand Up @@ -1035,6 +1058,35 @@ get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
g_free(raw_text);
}

#ifdef AQBANKING6
//if (optical_challenge)
if(mimeType != NULL && pChallenge != NULL && lChallenge > 0)
{
// convert PNG and load into widget
// TBD: check mimeType?
guchar *gudata = (guchar*)pChallenge;

GError *error = NULL;
GdkPixbufLoader *loader = gdk_pixbuf_loader_new_with_mime_type(mimeType, &error);
GdkPixbuf *pixbuf;

if(error != NULL)
{
PERR("Pixbuf loader not loaded: %s, perhaps MIME type %s isn't supported.", error->message, mimeType);
}

gdk_pixbuf_loader_write(loader, gudata, lChallenge, NULL);
gdk_pixbuf_loader_close(loader, NULL);

pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);

g_object_ref(pixbuf);
g_object_unref(loader);

gtk_image_set_from_pixbuf(optical_challenge, pixbuf);
}
#endif

if (*input)
{
gtk_entry_set_text(GTK_ENTRY(input_entry), *input);
Expand Down Expand Up @@ -1170,7 +1222,11 @@ inputbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,

ENTER("gui=%p, flags=%d", gui, flags);

#ifndef AQBANKING6
get_input(gui, flags, title, text, &input, min_len, max_len);
#else
get_input(gui, flags, title, text, NULL, NULL, 0, &input, min_len, max_len);
#endif

if (input)
{
Expand Down Expand Up @@ -1406,7 +1462,7 @@ progress_end_cb(GWEN_GUI *gwen_gui, guint32 id)
}

static gint GNC_GWENHYWFAR_CB
#ifndef GWENHYWFAR5
#ifndef AQBANKING6
getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
const gchar *title, const gchar *text, gchar *buffer,
gint min_len, gint max_len, guint32 guiid)
Expand All @@ -1421,8 +1477,46 @@ getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
gchar *password = NULL;
gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;

#ifdef AQBANKING6
int opticalMethodId;
const char *mimeType = NULL;
const char *pChallenge = NULL;
uint32_t lChallenge = 0;
#endif

g_return_val_if_fail(gui, -1);

#ifdef AQBANKING6
// cf. https://www.aquamaniac.de/rdm/projects/aqbanking/wiki/ImplementTanMethods
if(is_tan && methodId == GWEN_Gui_PasswordMethod_OpticalHHD)
{
/**
* TODO: How to handle Flicker code (use WebView and JS???)
*
* use GWEN_Gui_PasswordMethod_Mask to get the basic method id
* cf. gui/gui.h of gwenhywfar
*/
opticalMethodId=GWEN_DB_GetIntValue(methodParams, "tanMethodId", 0, AB_BANKING_TANMETHOD_TEXT);
switch(opticalMethodId)
{
case AB_BANKING_TANMETHOD_PHOTOTAN:
case AB_BANKING_TANMETHOD_CHIPTAN_QR:
/**
* image data is in methodParams
*/
mimeType=GWEN_DB_GetCharValue(methodParams, "mimeType", 0, NULL);
pChallenge=(const char*) GWEN_DB_GetBinValue(methodParams, "imageData", 0, NULL, 0, &lChallenge);
if (!(pChallenge && lChallenge)) {
/* empty optical data */
return GWEN_ERROR_NO_DATA;
}
break;
default:
break;
}
}
#endif

ENTER("gui=%p, flags=%d, token=%s", gui, flags, token ? token : "(null");

/* Check remembered passwords, excluding TANs */
Expand Down Expand Up @@ -1450,7 +1544,11 @@ getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
}
}

#ifndef AQBANKING6
get_input(gui, flags, title, text, &password, min_len, max_len);
#else
get_input(gui, flags, title, text, mimeType, pChallenge, lChallenge, &password, min_len, max_len);
#endif

if (password)
{
Expand Down
19 changes: 5 additions & 14 deletions gnucash/report/html-document.scm
Expand Up @@ -105,20 +105,11 @@
(apply gnc:make-html-data-style-info rest)
(apply gnc:make-html-markup-style-info rest))))

(define (gnc:html-document-tree-collapse tree)
(let ((retval '()))
(let loop ((lst tree))
(for-each
(lambda (elt)
(cond
((string? elt)
(set! retval (cons elt retval)))
((not (list? elt))
(set! retval (cons (object->string elt) retval)))
(else
(loop elt))))
lst))
retval))
(define (gnc:html-document-tree-collapse . tree)
(let lp ((e tree) (accum '()))
(cond ((list? e) (fold lp accum e))
((string? e) (cons e accum))
(else (cons (object->string e) accum)))))

;; first optional argument is "headers?"
;; returns the html document as a string, I think.
Expand Down

0 comments on commit 8403404

Please sign in to comment.