gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: implement #6825


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: implement #6825
Date: Sun, 04 Apr 2021 16:41:56 +0200

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 0d7307a  implement #6825
0d7307a is described below

commit 0d7307a4c428538e854a383db146a33a9b20a2ca
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 4 16:41:54 2021 +0200

    implement #6825
---
 configure.ac                                       |   6 +
 contrib/anastasis_gtk_challenge_question.glade     |   7 +-
 src/anastasis/Makefile.am                          |   1 +
 src/anastasis/anastasis-gtk_action.c               |  37 ++-
 ...stasis-gtk_handle-main-window-forward-clicked.c |   7 +-
 .../anastasis-gtk_handle-secret-buttons.c          | 176 +++++++++++--
 src/testing/test_prepare.sh                        | 274 +++++++++++----------
 7 files changed, 355 insertions(+), 153 deletions(-)

diff --git a/configure.ac b/configure.ac
index 50faaee..2247320 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,12 @@ AS_CASE(["$host_os"],
 
 AM_CONDITIONAL(MINGW,   test "$build_target" = "mingw")
 
+AC_MSG_CHECKING(for magic_open -lmagic)
+SAVED_AM_LDFLAGS=$AM_LDFLAGS
+AC_CHECK_LIB(magic, magic_open,
+  [AC_CHECK_HEADERS([magic.h],,
+   AC_MSG_ERROR([anastasis-gtk requires magic.h]))],
+  AC_MSG_ERROR([anastasis-gtk requires libmagic]))
 
 
 AC_SUBST(ENABLE_ON_UNIX)
diff --git a/contrib/anastasis_gtk_challenge_question.glade 
b/contrib/anastasis_gtk_challenge_question.glade
index 36f5816..ba89d11 100644
--- a/contrib/anastasis_gtk_challenge_question.glade
+++ b/contrib/anastasis_gtk_challenge_question.glade
@@ -20,7 +20,7 @@
                 <property name="label" translatable="yes">Cancel</property>
                 <property name="visible">True</property>
                 <property name="can-focus">True</property>
-                <property name="receives-default">True</property>
+                <property name="receives-default">False</property>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -34,7 +34,9 @@
                 <property name="visible">True</property>
                 <property name="sensitive">False</property>
                 <property name="can-focus">False</property>
-                <property name="receives-default">True</property>
+                <property name="can-default">True</property>
+                <property name="has-default">True</property>
+                <property name="receives-default">False</property>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -161,6 +163,7 @@
                 <property name="visible">True</property>
                 <property name="can-focus">True</property>
                 <property name="hexpand">True</property>
+                <property name="activates-default">True</property>
                 <property name="width-chars">60</property>
                 <property 
name="primary-icon-stock">gtk-dialog-authentication</property>
                 <signal name="changed" 
handler="anastasis_gtk_c_question_dialog_answer_entry_changed_cb" swapped="no"/>
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 916ddc2..68031aa 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -57,6 +57,7 @@ anastasis_gtk_LDADD = \
   -ltalerutil \
   -lanastasisrest \
   -lanastasisredux \
+  -lmagic \
   $(INTLLIBS)
 anastasis_gtk_CFLAGS = \
   @QR_CFLAGS@
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index 171a9c8..8ac7b25 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -2339,13 +2339,14 @@ static void
 action_recovery_finished (void)
 {
   GtkLabel *l;
-  const char *secret;
+  const char *mime;
   void *data;
   size_t data_size;
+  const json_t *cs;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_string ("core_secret",
-                             &secret),
-    GNUNET_JSON_spec_varsize ("core_secret",
+    GNUNET_JSON_spec_string ("mime",
+                             &mime),
+    GNUNET_JSON_spec_varsize ("value",
                               &data,
                               &data_size),
     GNUNET_JSON_spec_end ()
@@ -2356,12 +2357,34 @@ action_recovery_finished (void)
   AG_hide_all_frames ();
   l = GTK_LABEL (GCG_get_main_window_object (
                    "anastasis_gtk_secret_value_label"));
+  cs = json_object_get (AG_redux_state,
+                        "core_secret");
+  GNUNET_assert (NULL != cs);
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_JSON_parse (AG_redux_state,
+                 GNUNET_JSON_parse (cs,
                                     spec,
                                     NULL, NULL));
-  gtk_label_set_text (l,
-                      secret);
+  AG_hide ("anastasis_gtk_secret_copy_button");
+  if (0 == strncasecmp (mime,
+                        "text/",
+                        strlen ("text/")))
+  {
+    char *secret = GNUNET_strndup (data,
+                                   data_size);
+
+    gtk_label_set_text (l,
+                        secret);
+    GNUNET_free (secret);
+    /* offer copying secret text to clipboard */
+    AG_show ("anastasis_gtk_secret_copy_button");
+  }
+  if (0 == strncasecmp (mime,
+                        "image/",
+                        strlen ("image/")))
+  {
+    /* images we can copy, too */
+    AG_show ("anastasis_gtk_secret_copy_button");
+  }
   pb = setup_qrcode ("anastasis_gtk_secret_qr_image",
                      data,
                      data_size);
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c 
b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
index 58550ac..006eb22 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
@@ -169,10 +169,13 @@ forward_secret_editing (void)
   entry = GTK_ENTRY (GCG_get_main_window_object (
                        "anastasis_gtk_enter_secret_entry"));
   str = gtk_entry_get_text (entry);
-  arguments = json_pack ("{s:o}",
+  arguments = json_pack ("{s:{s:o,s:s}}",
                          "secret",
+                         "value",
                          GNUNET_JSON_from_data (str,
-                                                strlen (str)));
+                                                strlen (str)),
+                         "mime",
+                         "text/plain");
   AG_freeze ();
   AG_ra = ANASTASIS_redux_action (AG_redux_state,
                                   "enter_secret",
diff --git a/src/anastasis/anastasis-gtk_handle-secret-buttons.c 
b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
index 226688c..1a2db3f 100644
--- a/src/anastasis/anastasis-gtk_handle-secret-buttons.c
+++ b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
@@ -28,6 +28,13 @@
 #include "anastasis-gtk_action.h"
 #include "anastasis-gtk_helper.h"
 #include <jansson.h>
+#include <magic.h>
+
+
+/**
+ * Global handle to MAGIC data.
+ */
+static magic_t magic;
 
 
 /**
@@ -46,6 +53,7 @@ open_secret_dialog_response_cb (GtkDialog *dialog,
   char *filename;
   size_t data_size;
   void *data;
+  const char *mime;
 
   if (GTK_RESPONSE_OK != response_id)
   {
@@ -112,14 +120,21 @@ open_secret_dialog_response_cb (GtkDialog *dialog,
     GNUNET_DISK_file_close (fh);
   }
   GNUNET_free (filename);
+  mime = magic_buffer (magic,
+                       data,
+                       data_size);
   {
     json_t *arguments;
 
-    arguments = json_pack ("{s:o}",
+    arguments = json_pack ("{s:{s:o,s:s?}}",
                            "secret",
+                           "value",
                            GNUNET_JSON_from_data (data,
-                                                  data_size));
+                                                  data_size),
+                           "mime",
+                           mime);
     GNUNET_free (data);
+    GNUNET_assert (NULL != arguments);
     AG_freeze ();
     AG_ra = ANASTASIS_redux_action (AG_redux_state,
                                     "enter_secret",
@@ -144,6 +159,8 @@ anastasis_gtk_enter_secret_open_button_clicked_cb 
(GtkButton *button,
   GtkWidget *ad;
   GtkBuilder *builder;
 
+  (void) button;
+  (void) user_data;
   builder = GNUNET_GTK_get_new_builder (
     "anastasis_gtk_open_secret_dialog.glade",
     NULL);
@@ -181,8 +198,9 @@ save_secret_dialog_response_cb (GtkDialog *dialog,
   char *filename;
   size_t data_len;
   void *data;
-  struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_varsize ("core_secret",
+  json_t *cs;
+  struct GNUNET_JSON_Specification cspec[] = {
+    GNUNET_JSON_spec_varsize ("value",
                               &data,
                               &data_len),
     GNUNET_JSON_spec_end ()
@@ -198,10 +216,12 @@ save_secret_dialog_response_cb (GtkDialog *dialog,
     GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
   gtk_widget_destroy (GTK_WIDGET (dialog));
   g_object_unref (G_OBJECT (builder));
-
+  cs = json_object_get (AG_redux_state,
+                        "core_secret");
+  GNUNET_assert (NULL != cs);
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_JSON_parse (AG_redux_state,
-                                    spec,
+                 GNUNET_JSON_parse (cs,
+                                    cspec,
                                     NULL, NULL));
   {
     enum GNUNET_GenericReturnValue ret;
@@ -225,7 +245,7 @@ save_secret_dialog_response_cb (GtkDialog *dialog,
       break;
     }
   }
-  GNUNET_JSON_parse_free (spec);
+  GNUNET_JSON_parse_free (cspec);
   GNUNET_free (filename);
 }
 
@@ -240,9 +260,55 @@ void
 anastasis_gtk_secret_save_as_button_clicked_cb (GtkButton *button,
                                                 gpointer user_data)
 {
+  static const struct
+  {
+    const char *mime;
+    const char *fn;
+  } mime_map [] = {
+    { .mime = "text/plain",
+      .fn = "untitled.txt" },
+    { .mime = "text/html",
+      .fn = "untitled.html" },
+    { .mime = "text/xml",
+      .fn = "untitled.xml" },
+    { .mime = "text/csv",
+      .fn = "untitled.csv" },
+    { .mime = "image/jpeg",
+      .fn = "untitled.jpeg" },
+    { .mime = "image/png",
+      .fn = "untitled.png" },
+    { .mime = "application/pgp-keys",
+      .fn = "untitled.pgp" },
+    { .mime = "application/json",
+      .fn = "untitled.json" },
+    { .mime = "application/taler-wallet-secret",
+      .fn = "untitled.tws" },
+    { .mime = "application/taler-wallet",
+      .fn = "untitled.twd" },
+    { .mime = NULL,
+      .fn = NULL }
+  };
+
   GtkWidget *ad;
   GtkBuilder *builder;
+  const char *mime;
+  const char *fn;
+  json_t *cs;
+  struct GNUNET_JSON_Specification spec[] = {
+    GNUNET_JSON_spec_string ("mime",
+                             &mime),
+    GNUNET_JSON_spec_end ()
+  };
 
+  (void) button;
+  (void) user_data;
+  cs = json_object_get (AG_redux_state,
+                        "core_secret");
+  GNUNET_assert (NULL != cs);
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_JSON_parse (cs,
+                                    spec,
+                                    NULL, NULL));
   builder = GNUNET_GTK_get_new_builder (
     "anastasis_gtk_save_secret_dialog.glade",
     NULL);
@@ -253,8 +319,17 @@ anastasis_gtk_secret_save_as_button_clicked_cb (GtkButton 
*button,
   }
   ad = GTK_WIDGET (gtk_builder_get_object (builder,
                                            "save_file_dialog"));
+  fn = "untitled.secret";
+  for (unsigned int i = 0; NULL != mime_map[i].mime; i++)
+  {
+    if (0 != strcmp (mime_map[i].mime,
+                     mime))
+      continue;
+    fn = mime_map[i].fn;
+    break;
+  }
   gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (ad),
-                                     "untitled.secret");
+                                     fn);
   {
     GtkWidget *toplevel;
 
@@ -278,22 +353,95 @@ anastasis_gtk_secret_copy_button_clicked_cb (GtkButton 
*button,
 {
   size_t data_len;
   void *data;
+  const char *mime;
+  json_t *cs;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_varsize ("core_secret",
+    GNUNET_JSON_spec_varsize ("value",
                               &data,
                               &data_len),
+    GNUNET_JSON_spec_string ("mime",
+                             &mime),
     GNUNET_JSON_spec_end ()
   };
   GtkClipboard *cb;
 
+  (void) button;
+  (void) user_data;
+  cs = json_object_get (AG_redux_state,
+                        "core_secret");
+  GNUNET_assert (NULL != cs);
   GNUNET_assert (GNUNET_OK ==
-                 GNUNET_JSON_parse (AG_redux_state,
+                 GNUNET_JSON_parse (cs,
                                     spec,
                                     NULL, NULL));
   cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
   GNUNET_assert (NULL != cb);
-  gtk_clipboard_set_text (cb,
-                          data,
-                          data_len);
+  if (0 == strncasecmp (mime,
+                        "text/",
+                        strlen ("text/")))
+  {
+    gtk_clipboard_set_text (cb,
+                            data,
+                            data_len);
+  }
+  else if (0 == strncasecmp (mime,
+                             "image/",
+                             strlen ("image/")))
+  {
+    GdkPixbufLoader *loader;
+
+    loader = gdk_pixbuf_loader_new_with_mime_type (mime,
+                                                   NULL);
+    if (NULL != loader)
+    {
+      GdkPixbuf *pb;
+
+      gdk_pixbuf_loader_write (loader,
+                               data,
+                               data_len,
+                               NULL);
+      pb = gdk_pixbuf_loader_get_pixbuf (loader);
+      if (NULL != pb)
+      {
+        gtk_clipboard_set_image (cb,
+                                 pb);
+        g_object_unref (pb);
+      }
+      g_object_unref (loader);
+    }
+  }
+  else
+  {
+    GNUNET_break (0);
+  }
   GNUNET_JSON_parse_free (spec);
 }
+
+
+/**
+ * Constructor for the library.  Loads the magic file.
+ */
+void __attribute__ ((constructor))
+mime_ltdl_init ()
+{
+  magic = magic_open (MAGIC_MIME_TYPE);
+  if (0 != magic_load (magic,
+                       NULL))
+  {
+    /* FIXME: how to deal with errors? */
+  }
+}
+
+
+/**
+ * Destructor for the library, cleans up.
+ */
+void __attribute__ ((destructor))
+mime_ltdl_fini ()
+{
+  if (NULL != magic)
+  {
+    magic_close (magic);
+    magic = NULL;
+  }
+}
diff --git a/src/testing/test_prepare.sh b/src/testing/test_prepare.sh
index 825f818..355cec4 100755
--- a/src/testing/test_prepare.sh
+++ b/src/testing/test_prepare.sh
@@ -99,65 +99,71 @@ anastasis-dbinit -c $CONF_4 2> anastasis-dbinit_4.log
 
 echo " OK"
 
-echo -n "Generating Taler auditor, exchange and merchant configurations ..."
-
-DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
-rm -rf $DATA_DIR
-
-# obtain key configuration data
-MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE -o MASTER_PRIV_FILE`
-MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
-mkdir -p $MASTER_PRIV_DIR
-gnunet-ecc -g1 $MASTER_PRIV_FILE > /dev/null 2> /dev/null
-MASTER_PUB=`gnunet-ecc -p $MASTER_PRIV_FILE`
-EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
-MERCHANT_PORT=`taler-config -c $CONF -s MERCHANT -o PORT`
-MERCHANT_URL=http://localhost:${MERCHANT_PORT}/
-BANK_PORT=`taler-config -c $CONF -s BANK -o HTTP_PORT`
-BANK_URL=http://localhost:${BANK_PORT}/
-AUDITOR_URL=http://localhost:8083/
-AUDITOR_PRIV_FILE=`taler-config -f -c $CONF -s AUDITOR -o AUDITOR_PRIV_FILE`
-AUDITOR_PRIV_DIR=`dirname $AUDITOR_PRIV_FILE`
-mkdir -p $AUDITOR_PRIV_DIR
-gnunet-ecc -g1 $AUDITOR_PRIV_FILE > /dev/null 2> /dev/null
-AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
-
-# patch configuration
-TALER_DB=talercheck
-taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
-taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
-taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
-taler-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
-taler-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
-
-echo " OK"
-
-echo -n "Setting up exchange ..."
-
-# reset database
-dropdb $TALER_DB >/dev/null 2>/dev/null || true
-createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
-taler-exchange-dbinit -c $CONF
-taler-merchant-dbinit -c $CONF
-taler-auditor-dbinit -c $CONF
-taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
+if test $1 = 'fees'
+then
 
-echo " OK"
+    echo -n "Generating Taler auditor, exchange and merchant configurations 
..."
+
+    DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
+    rm -rf $DATA_DIR
+
+    # obtain key configuration data
+    MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE -o MASTER_PRIV_FILE`
+    MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
+    mkdir -p $MASTER_PRIV_DIR
+    gnunet-ecc -g1 $MASTER_PRIV_FILE > /dev/null 2> /dev/null
+    MASTER_PUB=`gnunet-ecc -p $MASTER_PRIV_FILE`
+    EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
+    MERCHANT_PORT=`taler-config -c $CONF -s MERCHANT -o PORT`
+    MERCHANT_URL=http://localhost:${MERCHANT_PORT}/
+    BANK_PORT=`taler-config -c $CONF -s BANK -o HTTP_PORT`
+    BANK_URL=http://localhost:${BANK_PORT}/
+    AUDITOR_URL=http://localhost:8083/
+    AUDITOR_PRIV_FILE=`taler-config -f -c $CONF -s AUDITOR -o 
AUDITOR_PRIV_FILE`
+    AUDITOR_PRIV_DIR=`dirname $AUDITOR_PRIV_FILE`
+    mkdir -p $AUDITOR_PRIV_DIR
+    gnunet-ecc -g1 $AUDITOR_PRIV_FILE > /dev/null 2> /dev/null
+    AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
+
+    # patch configuration
+    TALER_DB=talercheck
+    taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
+    taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V 
$MASTER_PUB
+    taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V 
postgres:///$TALER_DB
+    taler-config -c $CONF -s auditordb-postgres -o CONFIG -V 
postgres:///$TALER_DB
+    taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V 
postgres:///$TALER_DB
+    taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
+    taler-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
+    taler-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
+
+    echo " OK"
+
+    echo -n "Setting up exchange ..."
+
+    # reset database
+    dropdb $TALER_DB >/dev/null 2>/dev/null || true
+    createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
+    taler-exchange-dbinit -c $CONF
+    taler-merchant-dbinit -c $CONF
+    taler-auditor-dbinit -c $CONF
+    taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
+
+    echo " OK"
+
+    # Launch services
+    echo -n "Launching taler services ..."
+    taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > 
taler-bank.log 2> taler-bank.err &
+    taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log &
+    taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log &
+    taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
+    taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
+    taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
+    taler-auditor-httpd -L INFO -c $CONF 2> taler-auditor-httpd.log &
+
+    echo " OK"
 
-# Launch services
-echo -n "Launching taler services ..."
-taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > taler-bank.log 
2> taler-bank.err &
-taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log &
-taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log &
-taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
-taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
-taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
-taler-auditor-httpd -L INFO -c $CONF 2> taler-auditor-httpd.log &
+fi
 
-echo " OK"
 
 echo -n "Launching anastasis services ..."
 PREFIX="" #valgrind
@@ -166,77 +172,83 @@ $PREFIX anastasis-httpd -c $CONF_2 2> 
anastasis-httpd_2.log &
 $PREFIX anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
 $PREFIX anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
 
-# Wait for bank to be available (usually the slowest)
-for n in `seq 1 50`
-do
-    echo -n "."
-    sleep 0.2
-    OK=0
-    # bank
-    wget --tries=1 --timeout=1 http://localhost:8082/ -o /dev/null -O 
/dev/null >/dev/null || continue
-    OK=1
-    break
-done
 
-if [ 1 != $OK ]
+if test $1 = 'fees'
 then
-    exit_skip "Failed to launch services (bank)"
-fi
 
-# Wait for all other taler services to be available
-for n in `seq 1 50`
-do
-    echo -n "."
-    sleep 0.1
-    OK=0
-    # exchange
-    wget --tries=1 --timeout=1 http://localhost:8081/seed -o /dev/null -O 
/dev/null >/dev/null || continue
-    # merchant
-    wget --tries=1 --timeout=1 http://localhost:9966/ -o /dev/null -O 
/dev/null >/dev/null || continue
-    # auditor
-    wget --tries=1 --timeout=1 http://localhost:8083/ -o /dev/null -O 
/dev/null >/dev/null || continue
-    OK=1
-    break
-done
+    # Wait for bank to be available (usually the slowest)
+    for n in `seq 1 50`
+    do
+        echo -n "."
+        sleep 0.2
+        OK=0
+        # bank
+        wget --tries=1 --timeout=1 http://localhost:8082/ -o /dev/null -O 
/dev/null >/dev/null || continue
+        OK=1
+        break
+    done
 
-if [ 1 != $OK ]
-then
-    exit_skip "Failed to launch taler services"
-fi
+    if [ 1 != $OK ]
+    then
+        exit_skip "Failed to launch services (bank)"
+    fi
 
-echo "OK"
+    # Wait for all other taler services to be available
+    for n in `seq 1 50`
+    do
+        echo -n "."
+        sleep 0.1
+        OK=0
+        # exchange
+        wget --tries=1 --timeout=1 http://localhost:8081/seed -o /dev/null -O 
/dev/null >/dev/null || continue
+        # merchant
+        wget --tries=1 --timeout=1 http://localhost:9966/ -o /dev/null -O 
/dev/null >/dev/null || continue
+        # auditor
+        wget --tries=1 --timeout=1 http://localhost:8083/ -o /dev/null -O 
/dev/null >/dev/null || continue
+        OK=1
+        break
+    done
 
-echo -n "Setting up keys ..."
-taler-exchange-offline -c $CONF \
-  download \
-  sign \
-  enable-account payto://x-taler-bank/localhost/Exchange \
-  enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
-  wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 \
-  upload &> taler-exchange-offline.log
+    if [ 1 != $OK ]
+    then
+        exit_skip "Failed to launch taler services"
+    fi
 
-echo -n "."
+    echo "OK"
+
+    echo -n "Setting up keys ..."
+    taler-exchange-offline -c $CONF \
+                           download \
+                           sign \
+                           enable-account 
payto://x-taler-bank/localhost/Exchange \
+                           enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS 
Auditor" \
+                           wire-fee now x-taler-bank TESTKUDOS:0.01 
TESTKUDOS:0.01 \
+                           upload &> taler-exchange-offline.log
 
-for n in `seq 1 3`
-do
     echo -n "."
-    OK=0
-    wget --tries=1 --timeout=1 http://localhost:8081/keys -o /dev/null -O 
/dev/null >/dev/null || continue
-    OK=1
-    break
-done
 
-if [ 1 != $OK ]
-then
-    exit_skip "Failed to setup keys"
-fi
+    for n in `seq 1 3`
+    do
+        echo -n "."
+        OK=0
+        wget --tries=1 --timeout=1 http://localhost:8081/keys -o /dev/null -O 
/dev/null >/dev/null || continue
+        OK=1
+        break
+    done
 
-echo " OK"
+    if [ 1 != $OK ]
+    then
+        exit_skip "Failed to setup keys"
+    fi
 
-echo -n "Setting up auditor signatures ..."
-taler-auditor-offline -c $CONF \
-  download sign upload &> taler-auditor-offline.log
-echo " OK"
+    echo " OK"
+
+    echo -n "Setting up auditor signatures ..."
+    taler-auditor-offline -c $CONF \
+                          download sign upload &> taler-auditor-offline.log
+    echo " OK"
+
+fi
 
 echo -n "Waiting for anastasis services ..."
 
@@ -264,17 +276,20 @@ then
 fi
 echo "OK"
 
-echo -n "Configuring merchant instance ..."
-# Setup merchant
+if test $1 = 'fees'
+then
 
-curl -H "Content-Type: application/json" -X POST -d 
'{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1",
 
"default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms"
 : 3600000},"default_pay_delay":{"d_ms": 3600000}}' 
http://localhost:9966/private/instances
+    echo -n "Configuring merchant instance ..."
+    # Setup merchant
 
-echo " OK"
+    curl -H "Content-Type: application/json" -X POST -d 
'{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1",
 
"default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms"
 : 3600000},"default_pay_delay":{"d_ms": 3600000}}' 
http://localhost:9966/private/instances
 
-echo -n "Preparing wallet"
-rm $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 
'withdrawTestBalance' \
-  "$(jq -n '
+    echo " OK"
+
+    echo -n "Preparing wallet"
+    rm $WALLET_DB
+    taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 
'withdrawTestBalance' \
+                     "$(jq -n '
     {
         amount: "TESTKUDOS:20",
         bankBaseUrl: $BANK_URL,
@@ -283,16 +298,19 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 
'withdrawTestBalance'
     --arg BANK_URL "$BANK_URL" \
     --arg EXCHANGE_URL "$EXCHANGE_URL"
   )" 2> /dev/null >/dev/null
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>/dev/null >/dev/null
-echo " OK"
+    taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>/dev/null 
>/dev/null
+    echo " OK"
 
+fi
 
 echo "You can now run anastasis-gtk in the shell we are starting now."
 echo "Exit the shell when done to terminate the test environment!"
-echo "Use 'taler-wallet-cli --wallet-db=\$WALLET_DB handle-uri \$PAY_URI -y' 
to pay"
 
-export WALLET_DB
-export PS1="\[\e]0;\u@\h: 
\w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\>ANA$
 "
+if test $1 = 'fees'
+then
+    echo "Use 'taler-wallet-cli --wallet-db=\$WALLET_DB handle-uri \$PAY_URI 
-y' to pay"
+    export WALLET_DB
+fi
 
 bash
 

-- 
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]