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 #6809


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: implement #6809
Date: Sun, 04 Apr 2021 17:13:43 +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 755dfac  implement #6809
755dfac is described below

commit 755dfac5a6d0199055da3621c8a5c871d0b97ef7
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 4 17:13:39 2021 +0200

    implement #6809
---
 configure.ac                                       | 22 +++++++++
 contrib/anastasis_gtk_edit_providers.glade         |  5 ++-
 src/anastasis/Makefile.am                          |  1 +
 ...astasis-gtk_handle-auth-edit-provider-clicked.c | 52 ++++++++++++++++++++++
 src/anastasis/anastasis-gtk_helper.h               |  9 +++-
 5 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2247320..bffadab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,28 @@ AS_IF([test "$anastasis" != 1],
 ])
 
 
+# check for libmicrohttpd
+microhttpd=0
+AC_MSG_CHECKING([for microhttpd])
+AC_ARG_WITH([microhttpd],
+            [AS_HELP_STRING([--with-microhttpd=PFX], [base of microhttpd 
installation])],
+            [AC_MSG_RESULT([given as $with_microhttpd])],
+            [AC_MSG_RESULT([not given])
+             with_microhttpd=yes])
+AS_CASE([$with_microhttpd],
+        [yes], [],
+        [no], [AC_MSG_ERROR([--with-microhttpd is required])],
+        [LDFLAGS="-L$with_microhttpd/lib $LDFLAGS"
+         CPPFLAGS="-I$with_microhttpd/include $CPPFLAGS"])
+AC_CHECK_LIB(microhttpd,MHD_start_daemon,
+  [AC_CHECK_HEADER([microhttpd.h],[microhttpd=1])])
+AS_IF([test $microhttpd = 0],
+  [AC_MSG_ERROR([[
+***
+*** You need libmicrohttpd to build this program.
+*** ]])])
+
+
 AC_MSG_CHECKING(for gtk)
 without_gtk=true
 PKG_CHECK_MODULES([GTK], [gtk+-3.0])
diff --git a/contrib/anastasis_gtk_edit_providers.glade 
b/contrib/anastasis_gtk_edit_providers.glade
index adbd5d0..330ad58 100644
--- a/contrib/anastasis_gtk_edit_providers.glade
+++ b/contrib/anastasis_gtk_edit_providers.glade
@@ -30,6 +30,8 @@ along with Anastasis-gtk.  If not, see 
<http://www.gnu.org/licenses/>.
       <column type="gchararray"/>
       <!-- column-name status -->
       <column type="gchararray"/>
+      <!-- column-name status_color -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkDialog" id="edit_provider_dialog">
@@ -161,7 +163,6 @@ along with Anastasis-gtk.  If not, see 
<http://www.gnu.org/licenses/>.
                 <child>
                   <object class="GtkFrame">
                     <property name="visible">True</property>
-                    <property name="sensitive">False</property>
                     <property name="can-focus">False</property>
                     <property name="margin-top">10</property>
                     <property name="label-xalign">0</property>
@@ -204,6 +205,7 @@ along with Anastasis-gtk.  If not, see 
<http://www.gnu.org/licenses/>.
                                     <child>
                                       <object class="GtkCellRendererText" 
id="status"/>
                                       <attributes>
+                                        <attribute 
name="foreground">2</attribute>
                                         <attribute name="text">1</attribute>
                                       </attributes>
                                     </child>
@@ -218,7 +220,6 @@ along with Anastasis-gtk.  If not, see 
<http://www.gnu.org/licenses/>.
                     <child type="label">
                       <object class="GtkLabel">
                         <property name="visible">True</property>
-                        <property name="sensitive">False</property>
                         <property name="can-focus">False</property>
                         <property name="label" translatable="yes">Known 
providers</property>
                         <attributes>
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 68031aa..9a2ec03 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -57,6 +57,7 @@ anastasis_gtk_LDADD = \
   -ltalerutil \
   -lanastasisrest \
   -lanastasisredux \
+  -lmicrohttpd \
   -lmagic \
   $(INTLLIBS)
 anastasis_gtk_CFLAGS = \
diff --git a/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c 
b/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
index 1c6edad..4bc6558 100644
--- a/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
@@ -30,6 +30,7 @@
 #include "anastasis-gtk_helper.h"
 #include "anastasis-gtk_handle-main-window-forward-clicked.h"
 #include <jansson.h>
+#include <microhttpd.h>
 
 
 void
@@ -182,11 +183,62 @@ anastasis_gtk_edit_provider_list_clicked_cb (GtkButton 
*object,
     const json_t *provider;
     json_object_foreach (providers, url, provider)
     {
+      uint32_t http_code;
+      uint32_t ec;
+      struct GNUNET_JSON_Specification spec[] = {
+        GNUNET_JSON_spec_mark_optional (
+          GNUNET_JSON_spec_uint32 ("http_status",
+                                   &http_code)),
+        GNUNET_JSON_spec_mark_optional (
+          GNUNET_JSON_spec_uint32 ("error_code",
+                                   &ec)),
+        GNUNET_JSON_spec_end ()
+      };
+      char *status;
+      const char *color;
+
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (provider,
+                             spec,
+                             NULL, NULL))
+      {
+        GNUNET_break (0);
+        json_dumpf (provider,
+                    stderr,
+                    JSON_INDENT (2));
+        continue;
+      }
+      if (MHD_HTTP_OK == http_code)
+      {
+        status = GNUNET_strdup (_ ("available"));
+        color = "green";
+      }
+      else if (0 == http_code)
+      {
+        GNUNET_asprintf (&status,
+                         _ ("Network failure: %s (#%u)"),
+                         TALER_ErrorCode_get_hint (ec),
+                         (unsigned int) ec);
+        color = "red";
+      }
+      else
+      {
+        GNUNET_asprintf (&status,
+                         _ ("HTTP %s (%u): %s (#%u)"),
+                         MHD_get_reason_phrase_for (http_code),
+                         (unsigned int) http_code,
+                         TALER_ErrorCode_get_hint (ec),
+                         (unsigned int) ec);
+        color = "red";
+      }
       gtk_list_store_insert_with_values (ls,
                                          NULL,
                                          -1,
                                          AG_PMC_PROVIDER_URL, url,
+                                         AG_PMC_PROVIDER_STATUS, status,
+                                         AG_PMC_PROVIDER_STATUS_COLOR, color,
                                          -1);
+      GNUNET_free (status);
     }
   }
   ad = GTK_WIDGET (gtk_builder_get_object (builder,
diff --git a/src/anastasis/anastasis-gtk_helper.h 
b/src/anastasis/anastasis-gtk_helper.h
index 02e8681..8da17f5 100644
--- a/src/anastasis/anastasis-gtk_helper.h
+++ b/src/anastasis/anastasis-gtk_helper.h
@@ -135,9 +135,14 @@ enum AG_ProviderModelColumns
   AG_PMC_PROVIDER_URL = 0,
 
   /**
-   * A gchararray. FIXME: initialize! -- #6809
+   * A gchararray.
+   */
+  AG_PMC_PROVIDER_STATUS = 1,
+
+  /**
+   * A gchararray.
    */
-  AG_PMC_PROVIDER_STATUS = 1
+  AG_PMC_PROVIDER_STATUS_COLOR = 2
 };
 
 

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