gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis-gtk] branch master updated: fix pay handling


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: fix pay handling
Date: Tue, 16 Mar 2021 17:39:08 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis-gtk.

The following commit(s) were added to refs/heads/master by this push:
     new 4c8b831  fix pay handling
4c8b831 is described below

commit 4c8b831f3cd1e512f8e7403f0c129711dfc0c9a9
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Tue Mar 16 17:39:05 2021 +0100

    fix pay handling
---
 contrib/anastasis_gtk_main_window.glade            | 164 ++++++--------
 src/anastasis/anastasis-gtk.c                      |  10 +-
 src/anastasis/anastasis-gtk_action.c               | 235 +++++++++++----------
 .../anastasis-gtk_handle-secret-buttons.c          |  90 ++++----
 4 files changed, 232 insertions(+), 267 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index c414e81..c184453 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -93,16 +93,6 @@ Author: Christian Grothoff, Dennis Neufeld
     <property name="stock">gtk-go-down</property>
     <property name="icon_size">6</property>
   </object>
-  <object class="GtkListStore" id="unpaid_qrcodes_liststore">
-    <columns>
-      <!-- column-name qr -->
-      <column type="GdkPixbuf"/>
-      <!-- column-name url -->
-      <column type="gchararray"/>
-      <!-- column-name provider -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
   <object class="GtkWindow" id="anastasis_gtk_main_window">
     <property name="can-focus">False</property>
     <property name="events">GDK_BUTTON_PRESS_MASK | 
GDK_STRUCTURE_MASK</property>
@@ -1359,8 +1349,9 @@ Author: Christian Grothoff, Dennis Neufeld
                                       <object class="GtkBox">
                                         <property 
name="visible">True</property>
                                         <property 
name="can-focus">False</property>
+                                        <property name="spacing">5</property>
                                         <child>
-                                          <object class="GtkBox" 
id="anastasis_gtk_main_window_unpaid_box">
+                                          <object class="GtkBox">
                                             <property 
name="visible">True</property>
                                             <property 
name="can-focus">False</property>
                                             <property 
name="orientation">vertical</property>
@@ -1368,97 +1359,72 @@ Author: Christian Grothoff, Dennis Neufeld
                                               <object class="GtkLabel">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="can-focus">False</property>
-                                                <property name="label" 
translatable="yes">Unpaid:</property>
+                                                <property name="label" 
translatable="yes">Please pay with GNU Taler:</property>
                                               </object>
                                               <packing>
-                                                <property 
name="expand">False</property>
-                                                <property 
name="fill">False</property>
+                                                <property 
name="expand">True</property>
+                                                <property 
name="fill">True</property>
                                                 <property 
name="padding">5</property>
                                                 <property 
name="position">0</property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <object 
class="GtkScrolledWindow">
+                                              <object class="GtkBox" 
id="anastasis_gtk_main_window_unpaid_box">
                                                 <property 
name="visible">True</property>
-                                                <property 
name="can-focus">True</property>
-                                                <property 
name="vscrollbar-policy">never</property>
-                                                <property 
name="shadow-type">etched-out</property>
+                                                <property 
name="can-focus">False</property>
+                                                <property 
name="margin-left">5</property>
+                                                <property 
name="margin-right">5</property>
+                                                <property 
name="margin-start">5</property>
+                                                <property 
name="margin-end">5</property>
+                                                <property 
name="margin-top">5</property>
+                                                <property 
name="margin-bottom">5</property>
+                                                <property 
name="orientation">vertical</property>
+                                                <property 
name="spacing">5</property>
                                                 <child>
-                                                  <object class="GtkViewport">
+                                                  <object class="GtkTreeView" 
id="unpaid_qr_treeview">
                                                     <property 
name="visible">True</property>
-                                                    <property 
name="can-focus">False</property>
+                                                    <property 
name="can-focus">True</property>
+                                                    <property 
name="model">unpaid_qrcodes_liststore</property>
+                                                    <property 
name="enable-search">False</property>
+                                                    <property 
name="search-column">1</property>
+                                                    <child 
internal-child="selection">
+                                                      <object 
class="GtkTreeSelection"/>
+                                                    </child>
                                                     <child>
-                                                      <object 
class="GtkTreeView" id="unpaid_qr_treeview">
-                                                        <property 
name="visible">True</property>
-                                                        <property 
name="can-focus">True</property>
-                                                        <property 
name="model">unpaid_qrcodes_liststore</property>
-                                                        <property 
name="headers-visible">False</property>
-                                                        <property 
name="enable-search">False</property>
-                                                        <child 
internal-child="selection">
-                                                          <object 
class="GtkTreeSelection" id="unpaid_qr_treeselection"/>
-                                                        </child>
+                                                      <object 
class="GtkTreeViewColumn">
+                                                        <property 
name="spacing">10</property>
+                                                        <property 
name="sizing">autosize</property>
+                                                        <property name="title" 
translatable="yes">Payment QR Code</property>
+                                                        <property 
name="expand">True</property>
                                                         <child>
-                                                          <object 
class="GtkTreeViewColumn">
-                                                            <property 
name="sizing">autosize</property>
-                                                            <property 
name="title" translatable="yes">Unpaid</property>
-                                                            <child>
-                                                            <object 
class="GtkCellRendererPixbuf" id="unpaid_pixbuf"/>
-                                                            <attributes>
+                                                          <object 
class="GtkCellRendererPixbuf" id="unpaid_pixbuf"/>
+                                                          <attributes>
                                                             <attribute 
name="pixbuf">0</attribute>
-                                                            </attributes>
-                                                            </child>
-                                                          </object>
+                                                          </attributes>
+                                                        </child>
+                                                      </object>
+                                                    </child>
+                                                    <child>
+                                                      <object 
class="GtkTreeViewColumn" id="Pay URI">
+                                                        <property 
name="sizing">autosize</property>
+                                                        <property name="title" 
translatable="yes">Taler Pay URI</property>
+                                                        <child>
+                                                          <object 
class="GtkCellRendererText" id="pay_uri"/>
+                                                          <attributes>
+                                                            <attribute 
name="text">1</attribute>
+                                                          </attributes>
                                                         </child>
                                                       </object>
                                                     </child>
                                                   </object>
+                                                  <packing>
+                                                    <property 
name="expand">True</property>
+                                                    <property 
name="fill">True</property>
+                                                    <property 
name="padding">5</property>
+                                                    <property 
name="position">1</property>
+                                                  </packing>
                                                 </child>
                                               </object>
-                                              <packing>
-                                                <property 
name="expand">False</property>
-                                                <property 
name="fill">True</property>
-                                                <property 
name="padding">5</property>
-                                                <property 
name="position">1</property>
-                                              </packing>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property 
name="expand">False</property>
-                                            <property 
name="fill">True</property>
-                                            <property 
name="padding">5</property>
-                                            <property 
name="position">0</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkBox">
-                                            <property 
name="visible">True</property>
-                                            <property 
name="can-focus">False</property>
-                                            <property 
name="orientation">vertical</property>
-                                            <child>
-                                              <object class="GtkLabel">
-                                                <property 
name="visible">True</property>
-                                                <property 
name="can-focus">False</property>
-                                                <property name="label" 
translatable="yes">Please pay with GNU Taler:</property>
-                                              </object>
-                                              <packing>
-                                                <property 
name="expand">True</property>
-                                                <property 
name="fill">True</property>
-                                                <property 
name="padding">5</property>
-                                                <property 
name="position">0</property>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <object class="GtkLabel" 
id="anastasis_gtk_pay_payto_label">
-                                                <property 
name="visible">True</property>
-                                                <property 
name="can-focus">False</property>
-                                                <property name="label" 
translatable="yes">payto://FIXME</property>
-                                                <property 
name="selectable">True</property>
-                                                <property 
name="ellipsize">end</property>
-                                                <attributes>
-                                                  <attribute name="underline" 
value="True"/>
-                                                  <attribute name="foreground" 
value="#1c1c7171d8d8"/>
-                                                </attributes>
-                                              </object>
                                               <packing>
                                                 <property 
name="expand">True</property>
                                                 <property 
name="fill">True</property>
@@ -1466,28 +1432,6 @@ Author: Christian Grothoff, Dennis Neufeld
                                                 <property 
name="position">1</property>
                                               </packing>
                                             </child>
-                                            <child>
-                                              <object class="GtkImage" 
id="anastasis_gtk_pay_qrcode_image">
-                                                <property 
name="width-request">400</property>
-                                                <property 
name="height-request">400</property>
-                                                <property 
name="visible">True</property>
-                                                <property 
name="sensitive">False</property>
-                                                <property 
name="can-focus">False</property>
-                                                <property name="tooltip-text" 
translatable="yes">Scan this QR code with your Taler wallet to pay.</property>
-                                                <property 
name="halign">center</property>
-                                                <property 
name="margin-start">10</property>
-                                                <property 
name="margin-end">10</property>
-                                                <property 
name="margin-top">10</property>
-                                                <property 
name="margin-bottom">10</property>
-                                                <property 
name="stock">gtk-missing-image</property>
-                                              </object>
-                                              <packing>
-                                                <property 
name="expand">True</property>
-                                                <property 
name="fill">True</property>
-                                                <property 
name="padding">5</property>
-                                                <property 
name="position">2</property>
-                                              </packing>
-                                            </child>
                                           </object>
                                           <packing>
                                             <property 
name="expand">True</property>
@@ -1968,4 +1912,14 @@ Author: Christian Grothoff, Dennis Neufeld
       </object>
     </child>
   </object>
+  <object class="GtkListStore" id="unpaid_qrcodes_liststore">
+    <columns>
+      <!-- column-name qr -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name url -->
+      <column type="gchararray"/>
+      <!-- column-name provider -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
 </interface>
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index e924e1f..ede645a 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -147,6 +147,11 @@ shutdown_task (void *cls)
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Shutdown initiated\n");
   ANASTASIS_redux_done ();
+  if (NULL != ra)
+  {
+    ANASTASIS_redux_action_cancel (ra);
+    ra = NULL;
+  }
   if (NULL != ctx)
   {
     GNUNET_CURL_fini (ctx);
@@ -161,11 +166,6 @@ shutdown_task (void *cls)
   ml = NULL;
   GNUNET_CONTAINER_multihashmap_destroy (AG_entry_attributes);
   AG_entry_attributes = NULL;
-  if (NULL != ra)
-  {
-    ANASTASIS_redux_action_cancel (ra);
-    ra = NULL;
-  }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Shutdown complete\n");
 }
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index 592549d..88229cc 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -844,7 +844,7 @@ action_secret_editing (void)
   const char *secret;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("core_secret",
-                            &secret),
+                             &secret),
     GNUNET_JSON_spec_end ()
   };
 
@@ -852,9 +852,9 @@ action_secret_editing (void)
   entry = GTK_ENTRY (GCG_get_main_window_object (
                        "anastasis_gtk_enter_secret_entry"));
   if ( (GNUNET_OK ==
-       GNUNET_JSON_parse (redux_state,
-                          spec,
-                          NULL, NULL)) &&
+        GNUNET_JSON_parse (redux_state,
+                           spec,
+                           NULL, NULL)) &&
        (0 < strlen (secret)) )
   {
     gtk_entry_set_text (entry,
@@ -885,7 +885,7 @@ action_secret_editing (void)
 static GdkPixbuf *
 create_qrcode (unsigned int scale,
                const char *text,
-              size_t text_size)
+               size_t text_size)
 {
   QRinput *qri;
   QRcode *qrc;
@@ -935,7 +935,7 @@ create_qrcode (unsigned int scale,
                    "%s%s",
                    dir,
                    "qr_dummy.png");
-  size = qrc->width * scale;
+  size = (qrc->width + 8) * scale;
   size += 8 - (size % 8);
   pb = gdk_pixbuf_new_from_file_at_size (fn,
                                          size,
@@ -950,11 +950,14 @@ create_qrcode (unsigned int scale,
   }
   pixels = gdk_pixbuf_get_pixels (pb);
   n_channels = gdk_pixbuf_get_n_channels (pb);
-  for (unsigned int x = 0; x < size; x++)
-    for (unsigned int y = 0; y < size; y++)
+  for (unsigned int x = 4 * scale; x < size - 4*scale; x++)
+    for (unsigned int y = 4 * scale; y < size- 4*scale; y++)
     {
+      unsigned int xx = x - 4 * scale;
+      unsigned int yy = y - 4 * scale;
+      unsigned int ss = size - 8 * scale;
       unsigned int off =
-        (x * qrc->width / size) + (y * qrc->width / size) * qrc->width;
+        (xx * qrc->width / ss) + (yy * qrc->width / ss) * qrc->width;
       for (int c = 0; c < n_channels; c++)
         pixels[(y * size + x) * n_channels + c] =
           (0 == (qrc->data[off] & 1)) ? 0xFF : 0;
@@ -974,7 +977,7 @@ create_qrcode (unsigned int scale,
 static GdkPixbuf *
 setup_qrcode (const char *widget,
               const char *text,
-             size_t text_size)
+              size_t text_size)
 {
   GtkWidget *image;
   GdkScreen *screen;
@@ -1005,7 +1008,7 @@ setup_qrcode (const char *widget,
     scale = 2;
   return create_qrcode (scale,
                         text,
-                       text_size);
+                        text_size);
 }
 
 
@@ -1015,9 +1018,12 @@ action_truths_paying (void)
   json_t *pprs;
   size_t index;
   json_t *pt;
+  GtkListStore *ls;
 
   AG_hide_all_frames ();
-
+  ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                                                  "unpaid_qrcodes_liststore"));
+  gtk_list_store_clear (ls);
   pprs = json_object_get (redux_state,
                           "payments");
   json_array_foreach (pprs, index, pt)
@@ -1030,9 +1036,9 @@ action_truths_paying (void)
       GNUNET_break (0);
       continue;
     }
-    pb = setup_qrcode ("anastasis_gtk_pay_qrcode_image",
+    pb = setup_qrcode ("unpaid_qr_treeview",
                        payto,
-                      strlen (payto));
+                       strlen (payto));
     if (NULL == pb)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1041,41 +1047,32 @@ action_truths_paying (void)
       continue;
     }
 
-    {
-      GtkListStore *ls;
-
-      ls = GTK_LIST_STORE (GCG_get_main_window_object (
-                             "unpaid_qrcodes_liststore"));
-      gtk_list_store_insert_with_values (ls,
-                                         NULL,
-                                         -1, /* append */
-                                         AG_UQRMC_QR_IMAGE, pb,
-                                         AG_UQRMC_URL, payto,
-                                         AG_UQRMC_PROVIDER, "",
-                                         -1);
-    }
-    if (0 == index)
-    {
-      GtkImage *image;
-      json_t *args;
-
-      image = GTK_IMAGE (GCG_get_main_window_object (
-                                                    
"anastasis_gtk_pay_qrcode_image"));
-      gtk_image_set_from_pixbuf (image,
-                                 pb);
-      GNUNET_assert (NULL == ra);
-      args = json_pack ("{s:s}",
-                        "payto_uri",
-                        payto);
-      ra = ANASTASIS_redux_action (redux_state,
-                                   "await_payment",
-                                   args,
-                                   &AG_action_cb,
-                                   NULL);
-      json_decref (args);
-    }
+    gtk_list_store_insert_with_values (ls,
+                                       NULL,
+                                       -1, /* append */
+                                       AG_UQRMC_QR_IMAGE, pb,
+                                       AG_UQRMC_URL, payto,
+                                       AG_UQRMC_PROVIDER, "",
+                                       -1);
     g_object_unref (pb);
   }
+
+  {
+    json_t *args;
+    struct GNUNET_TIME_Relative timeout;
+
+    timeout = GNUNET_TIME_UNIT_MINUTES;
+    GNUNET_assert (NULL == ra);
+    args = json_pack ("{s:o}",
+                      "timeout",
+                      GNUNET_JSON_from_time_rel (timeout));
+    ra = ANASTASIS_redux_action (redux_state,
+                                 "pay",
+                                 args,
+                                 &AG_action_cb,
+                                 NULL);
+    json_decref (args);
+  }
   AG_show ("anastasis_gtk_pay_frame");
   AG_show ("anastasis_gtk_pay_image");
   AG_show ("anastasis_gtk_main_control_vbox");
@@ -1090,8 +1087,12 @@ action_policies_paying (void)
   json_t *pprs;
   size_t index;
   json_t *ppr;
+  GtkListStore *ls;
 
   AG_hide_all_frames ();
+  ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                         "unpaid_qrcodes_liststore"));
+  gtk_list_store_clear (ls);
   pprs = json_object_get (redux_state,
                           "policy_payment_requests");
   json_array_foreach (pprs, index, ppr)
@@ -1115,9 +1116,9 @@ action_policies_paying (void)
       GNUNET_break (0);
       continue;
     }
-    pb = setup_qrcode ("anastasis_gtk_pay_qrcode_image",
+    pb = setup_qrcode ("unpaid_qr_treeview",
                        payto,
-                      strlen (payto));
+                       strlen (payto));
     if (NULL == pb)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1126,41 +1127,31 @@ action_policies_paying (void)
       continue;
     }
 
-    {
-      GtkListStore *ls;
-
-      ls = GTK_LIST_STORE (GCG_get_main_window_object (
-                             "unpaid_qrcodes_liststore"));
-      gtk_list_store_insert_with_values (ls,
-                                         NULL,
-                                         -1, /* append */
-                                         AG_UQRMC_QR_IMAGE, pb,
-                                         AG_UQRMC_URL, payto,
-                                         AG_UQRMC_PROVIDER, provider,
-                                         -1);
-    }
-    if (0 == index)
-    {
-      GtkImage *image;
-      json_t *args;
-
-      image = GTK_IMAGE (GCG_get_main_window_object (
-                           "anastasis_gtk_pay_qrcode_image"));
-      gtk_image_set_from_pixbuf (image,
-                                 pb);
-      GNUNET_assert (NULL == ra);
-      args = json_pack ("{s:s}",
-                        "payto_uri",
-                        payto);
-      ra = ANASTASIS_redux_action (redux_state,
-                                   "await_payment",
-                                   args,
-                                   &AG_action_cb,
-                                   NULL);
-      json_decref (args);
-    }
+    gtk_list_store_insert_with_values (ls,
+                                       NULL,
+                                       -1, /* append */
+                                       AG_UQRMC_QR_IMAGE, pb,
+                                       AG_UQRMC_URL, payto,
+                                       AG_UQRMC_PROVIDER, provider,
+                                       -1);
     g_object_unref (pb);
   }
+  {
+    json_t *args;
+    struct GNUNET_TIME_Relative timeout;
+
+    timeout = GNUNET_TIME_UNIT_MINUTES;
+    GNUNET_assert (NULL == ra);
+    args = json_pack ("{s:o}",
+                      "timeout",
+                      GNUNET_JSON_from_time_rel (timeout));
+    ra = ANASTASIS_redux_action (redux_state,
+                                 "pay",
+                                 args,
+                                 &AG_action_cb,
+                                 NULL);
+    json_decref (args);
+  }
   AG_show ("anastasis_gtk_pay_frame");
   AG_show ("anastasis_gtk_pay_image");
   AG_show ("anastasis_gtk_main_control_vbox");
@@ -1495,9 +1486,12 @@ action_challenge_paying (void)
   json_t *pprs;
   size_t index;
   json_t *ppr;
+  GtkListStore *ls;
 
-  // FIXME: json parser is wrong here!
   AG_hide_all_frames ();
+  ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                         "unpaid_qrcodes_liststore"));
+  gtk_list_store_clear (ls);
   pprs = json_object_get (redux_state,
                           "challenge_payment_requests");
   json_array_foreach (pprs, index, ppr)
@@ -1521,9 +1515,9 @@ action_challenge_paying (void)
       GNUNET_break (0);
       continue;
     }
-    pb = setup_qrcode ("anastasis_gtk_pay_qrcode_image",
+    pb = setup_qrcode ("unpaid_qr_treeview",
                        payto,
-                      strlen (payto));
+                       strlen (payto));
     if (NULL == pb)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1531,29 +1525,32 @@ action_challenge_paying (void)
                   payto);
       continue;
     }
-
-    if (0 == index)
-    {
-      GtkImage *image;
-      json_t *args;
-
-      image = GTK_IMAGE (GCG_get_main_window_object (
-                           "anastasis_gtk_pay_qrcode_image"));
-      gtk_image_set_from_pixbuf (image,
-                                 pb);
-      GNUNET_assert (NULL == ra);
-      args = json_pack ("{s:s}",
-                        "payto_uri",
-                        payto);
-      ra = ANASTASIS_redux_action (redux_state,
-                                   "await_payment",
-                                   args,
-                                   &AG_action_cb,
-                                   NULL);
-      json_decref (args);
-    }
+    gtk_list_store_insert_with_values (ls,
+                                       NULL,
+                                       -1, /* append */
+                                       AG_UQRMC_QR_IMAGE, pb,
+                                       AG_UQRMC_URL, payto,
+                                       AG_UQRMC_PROVIDER, provider,
+                                       -1);
     g_object_unref (pb);
   }
+
+  {
+    json_t *args;
+    struct GNUNET_TIME_Relative timeout;
+
+    timeout = GNUNET_TIME_UNIT_MINUTES;
+    GNUNET_assert (NULL == ra);
+    args = json_pack ("{s:o}",
+                      "timeout",
+                     GNUNET_JSON_from_time_rel (timeout));
+    ra = ANASTASIS_redux_action (redux_state,
+                                 "await_payment",
+                                 args,
+                                 &AG_action_cb,
+                                 NULL);
+    json_decref (args);
+  }
   AG_show ("anastasis_gtk_pay_frame");
   AG_show ("anastasis_gtk_pay_image");
   AG_show ("anastasis_gtk_main_control_vbox");
@@ -1708,7 +1705,7 @@ action_recovery_finished (void)
   size_t data_size;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("core_secret",
-                            &secret),
+                             &secret),
     GNUNET_JSON_spec_varsize ("core_secret",
                               &data,
                               &data_size),
@@ -1716,7 +1713,7 @@ action_recovery_finished (void)
   };
   GdkPixbuf *pb;
   GtkImage *img;
-  
+
   AG_hide_all_frames ();
   l = GTK_LABEL (GCG_get_main_window_object (
                    "anastasis_gtk_secret_value_label"));
@@ -1727,12 +1724,12 @@ action_recovery_finished (void)
   gtk_label_set_text (l,
                       secret);
   pb = setup_qrcode ("anastasis_gtk_secret_qr_image",
-                    data,
-                    data_size);
+                     data,
+                     data_size);
   img = GTK_IMAGE (GCG_get_main_window_object (
-                                              
"anastasis_gtk_secret_qr_image"));
+                     "anastasis_gtk_secret_qr_image"));
   gtk_image_set_from_pixbuf (img,
-                            pb);
+                             pb);
   g_object_unref (pb);
   GNUNET_JSON_parse_free (spec);
   AG_show ("anastasis_gtk_completed_frame");
@@ -1759,6 +1756,7 @@ AG_action_cb (void *cls,
               enum TALER_ErrorCode error_code,
               json_t *response)
 {
+  static bool in_action;
   struct DispatchItem actions[] = {
     { .state = "CONTINENT_SELECTING",
       .action = &action_continent_selecting },
@@ -1793,20 +1791,33 @@ AG_action_cb (void *cls,
   (void) cls;
   ra = NULL;
   AG_thaw ();
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             "Action result %d\n",
+             error_code);
   if (TALER_EC_NONE != error_code)
   {
     AG_error ("Error: %d\n",
               error_code);
     /* FIXME: show error *nicely* in UI! */
+    if (in_action)
+    {
+      GNUNET_break (0);
+      return;
+    }
   }
   else
   {
     json_decref (redux_state);
     redux_state = json_incref (response);
   }
+  in_action = true;
   if (GNUNET_OK ==
       AG_dispatch (actions))
+  {
+    in_action = false;
     return;
+  }
+  in_action = false;
   AG_error ("Unhandled state");
   json_dumpf (redux_state,
               stderr,
diff --git a/src/anastasis/anastasis-gtk_handle-secret-buttons.c 
b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
index 37e8321..897c609 100644
--- a/src/anastasis/anastasis-gtk_handle-secret-buttons.c
+++ b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
@@ -64,51 +64,51 @@ open_secret_dialog_response_cb (GtkDialog *dialog,
     enum GNUNET_GenericReturnValue ret;
 
     fh = GNUNET_DISK_file_open (filename,
-                               GNUNET_DISK_OPEN_READ,
-                               GNUNET_DISK_PERM_NONE);
+                                GNUNET_DISK_OPEN_READ,
+                                GNUNET_DISK_PERM_NONE);
     if (NULL == fh)
-      {
-       AG_error ("Failed to open file `%s': %s",
-                 filename,
-                 strerror (errno));
-       GNUNET_free (filename);
-       return;
-      }
+    {
+      AG_error ("Failed to open file `%s': %s",
+                filename,
+                strerror (errno));
+      GNUNET_free (filename);
+      return;
+    }
     ret = GNUNET_DISK_file_handle_size (fh,
-                                       &size);
+                                        &size);
     if (GNUNET_OK != ret)
-      {
-       AG_error ("Failed to obtain file size `%s': %s",
-                 filename,
-                 strerror (errno));
-       GNUNET_free (filename);
-       GNUNET_DISK_file_close (fh);
-       return;
-      }
+    {
+      AG_error ("Failed to obtain file size `%s': %s",
+                filename,
+                strerror (errno));
+      GNUNET_free (filename);
+      GNUNET_DISK_file_close (fh);
+      return;
+    }
     data_size = (size_t) size;
     data = GNUNET_malloc_large (data_size);
     if (GNUNET_OK != ret)
-      {
-       AG_error ("Failed to allocate memory for file `%s': %s",
-                 filename,
-                 strerror (errno));
-       GNUNET_free (filename);
-       GNUNET_DISK_file_close (fh);
-       return;
-      }
+    {
+      AG_error ("Failed to allocate memory for file `%s': %s",
+                filename,
+                strerror (errno));
+      GNUNET_free (filename);
+      GNUNET_DISK_file_close (fh);
+      return;
+    }
     if (size !=
-       GNUNET_DISK_file_read (fh,
-                              data,
-                              data_size))
-      {
-       AG_error ("Failed read file `%s': %s",
-                 filename,
-                 strerror (errno));
-       GNUNET_free (data);
-       GNUNET_free (filename);
-       GNUNET_DISK_file_close (fh);
-       return;
-      }
+        GNUNET_DISK_file_read (fh,
+                               data,
+                               data_size))
+    {
+      AG_error ("Failed read file `%s': %s",
+                filename,
+                strerror (errno));
+      GNUNET_free (data);
+      GNUNET_free (filename);
+      GNUNET_DISK_file_close (fh);
+      return;
+    }
     GNUNET_DISK_file_close (fh);
   }
   GNUNET_free (filename);
@@ -116,16 +116,16 @@ open_secret_dialog_response_cb (GtkDialog *dialog,
     json_t *arguments;
 
     arguments = json_pack ("{s:o}",
-                          "secret",
-                          GNUNET_JSON_from_data (data,
-                                                 data_size));
+                           "secret",
+                           GNUNET_JSON_from_data (data,
+                                                  data_size));
     GNUNET_free (data);
     AG_freeze ();
     ra = ANASTASIS_redux_action (redux_state,
-                                "enter_secret",
-                                arguments,
-                                &AG_action_cb,
-                                NULL);
+                                 "enter_secret",
+                                 arguments,
+                                 &AG_action_cb,
+                                 NULL);
     json_decref (arguments);
   }
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]