gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated (84b85a3 -> 742f9a7)


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated (84b85a3 -> 742f9a7)
Date: Mon, 28 Sep 2020 15:19:47 +0200

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

dennis-neufeld pushed a change to branch master
in repository anastasis-gtk.

    from 84b85a3  worked on authentication frames forward button
     new fb6dfee  fix config api response handling
     new 6278d34  serialize authentication methods
     new 742f9a7  work on initial policy

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/anastasis/Makefile.am            |   1 +
 src/anastasis/anastasis-gtk.c        |  22 +-
 src/anastasis/anastasis-gtk_backup.c | 412 ++++++++++++++++++++++++-----------
 src/anastasis/anastasis-gtk_helper.c |   6 +-
 src/include/anastasis-gtk_helper.h   |  16 +-
 5 files changed, 320 insertions(+), 137 deletions(-)

diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 56d9ca9..34fc75b 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -24,6 +24,7 @@ anastasis_gtk_LDADD = \
   -lgnunetutil \
   -lgnunetcurl \
   -ljansson \
+  -ltalerjson \
   -lanastasisrest \
   -lanastasisredux \
   $(INTLLIBS)
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 470d557..c8a713b 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -27,7 +27,8 @@
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet-gtk/gnunet_gtk.h>
-#include "anastasis-gtk_helper.h"
+#include <gtk/gtk.h>
+#include <anastasis-gtk/anastasis-gtk_helper.h>
 #include <jansson.h>
 
 /**
@@ -81,7 +82,7 @@ anastasis_gtk_animation_activate_cb (GtkMenuItem *menuitem,
           if (NULL == path)
           {
             GNUNET_break (0);
-            return GNUNET_SYSERR;
+            return;
           }
 
           //continent selection
@@ -319,7 +320,7 @@ void
 anastasis_gtk_main_window_back_clicked (GObject *object,
                                         gpointer user_data)
 {
-    char *state = json_string_value (json_object_get (redux_state, 
"backup-state"));
+    const char *state = json_string_value (json_object_get (redux_state, 
"backup-state"));
     if (!state)
         state = json_string_value (json_object_get (redux_state, 
"recovery-state"));
     GNUNET_assert (state);
@@ -404,7 +405,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
             bool isset = false;
             char *entry_widget;
             char *cal_widget;
-            char *widget = gtk_buildable_get_name (iter->data);
+            const char *widget = gtk_buildable_get_name (iter->data);
             json_t *id_attr = json_object ();
 
             GNUNET_asprintf (&entry_widget,
@@ -475,9 +476,18 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
 
     //show backup policy frame, hide backup authentication methods frame
     if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_authentication_frame")))
+                                        
"anastasis_gtk_b_authentication_frame"))))
     {
-        
+        if (check_state (redux_state, "ReduxUserAttributesAddedState"))
+        {
+            GList *children;
+
+            children = gtk_container_get_children (GTK_CONTAINER 
(GCG_get_main_window_object (
+                                                                    
"anastasis_gtk_b_authentication_vbox")));
+            if (g_list_length (children) > 0)
+                init_b_policy (redux_state);
+            g_list_free (children);
+        }
     }
 }
 
diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index 364e55c..bc5c156 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -27,8 +27,9 @@
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet-gtk/gnunet_gtk.h>
+#include <taler/taler_json_lib.h>
 #include <gtk/gtk.h>
-#include "anastasis-gtk_helper.h"
+#include <anastasis-gtk/anastasis-gtk_helper.h>
 #include <jansson.h>
 
 
@@ -43,34 +44,34 @@ struct ServerInfo
   char *backend_url;
 
   /**
-   * label of the anastasis backend.
+   * id of the anastasis backend.
    */
-  const char *backend_label;
+  char *backend_id;
 
   /**
-   * supported methods of the anastasis backend.
+   * label of the anastasis backend.
    */
-  char *backend_methods;
+  char *backend_name;
 
   /**
-   * server salt of the anastasis backend.
+   * currrency used by the anastasis backend.
    */
-  const struct ANASTASIS_CRYPTO_PowSalt *backend_salt;
+  char *backend_currency;
 
   /**
-   * insurance of the anastasis backend.
+   * supported methods of the anastasis backend.
    */
-  const struct TALER_Amount *backend_insurance;
+  json_t *backend_methods;
 
   /**
-   * cost of using the anastasis backend.
+   * insurance of the anastasis backend.
    */
-  const struct TALER_Amount *backend_cost;
+  struct TALER_Amount backend_insurance;
 
   /**
-   * user identifier derived from user data and backend salt
+   * cost of using the anastasis backend.
    */
-  struct ANASTASIS_CRYPTO_UserIdentifierP *user_id;
+  struct TALER_Amount backend_cost;
 };
 
 /**
@@ -92,8 +93,23 @@ struct ConfigState
    * Reference to a ServerInfo.
    */
   struct ServerInfo *server;
+
+  /**
+   * Supported methods.
+   */
+  json_t *methods;
 };
 
+/**
+ * Information about the servers.
+ */
+static struct ServerInfo *servers;
+
+/**
+ * Amount of servers.
+ */
+static unsigned int servers_length = 0;
+
 guint g_signal_question;
 guint g_signal_sms;
 guint g_signal_email;
@@ -189,15 +205,15 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb 
(GObject *object,
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      // set labels
      GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("Q: ");
-     gchar *question = gtk_entry_get_text (
+     const gchar *question = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_question_entry")));
      GtkLabel *label_question = (GtkLabel *) gtk_label_new (question);
-     gchar *answer = gtk_entry_get_text (
+     const gchar *answer = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_answer_entry")));
      GtkLabel *label_answer = (GtkLabel *) gtk_label_new (answer);
 
      // set buttons
-     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
+     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
      GtkButton  *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
      g_signal_connect (edit_btn, 
                        "clicked", 
@@ -208,17 +224,17 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb 
(GObject *object,
                        "clicked", 
                        G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
                        hbox);
-     gtk_box_pack_start (buttons, edit_btn, 0, 0, 0);
-     gtk_box_pack_start (buttons, delete_btn, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (edit_btn), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (delete_btn), 0, 0, 0);
      
-     gtk_box_pack_start (hbox, label_prefix, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_question, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_answer, 0, 0, 0);
-     gtk_box_pack_end (hbox, buttons, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_prefix), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_question), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_answer), 0, 0, 0);
+     gtk_box_pack_end (GTK_BOX (hbox), GTK_WIDGET (buttons), 0, 0, 0);
 
      if (! is_box)
      {
-          gtk_box_pack_start (vbox, hbox, 0, 0, 0);
+          gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), 0, 0, 0);
      }
 
      gtk_widget_show (GTK_WIDGET (hbox));
@@ -252,8 +268,8 @@ anastasis_gtk_btn_add_auth_question_clicked_cb (GObject 
*object,
 {
      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_b_question_dialog")));
-     GtkButton *ok_btn = GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_question_dialog_btn_ok");
+     GtkButton *ok_btn = GTK_BUTTON (GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_question_dialog_btn_ok"));
      if (g_signal_question > 0)
           g_signal_handler_disconnect (ok_btn, g_signal_question);
      g_signal_question = g_signal_connect(ok_btn, 
@@ -308,24 +324,24 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject 
*object,
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      // set labels
      GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("POST: ");
-     gchar *full_name = gtk_entry_get_text (
+     const gchar *full_name = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_post_dialog_full_name_entry")));
      GtkLabel *label_full_name = (GtkLabel *) gtk_label_new (full_name);
-     gchar *street = gtk_entry_get_text (
+     const gchar *street = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_post_dialog_street_entry")));
      GtkLabel *label_street = (GtkLabel *) gtk_label_new (street);
-     gchar *city = gtk_entry_get_text (
+     const gchar *city = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_post_dialog_city_entry")));
      GtkLabel *label_city = (GtkLabel *) gtk_label_new (city);
-     gchar *postcode = gtk_entry_get_text (
+     const gchar *postcode = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_post_dialog_postcode_entry")));
      GtkLabel *label_postcode = (GtkLabel *) gtk_label_new (postcode);
-     gchar *country = gtk_entry_get_text (
+     const gchar *country = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_post_dialog_country_entry")));
      GtkLabel *label_country = (GtkLabel *) gtk_label_new (country);
 
      // set buttons
-     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
+     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
      GtkButton  *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
      g_signal_connect (edit_btn, 
                        "clicked", 
@@ -336,20 +352,20 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject 
*object,
                        "clicked", 
                        G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
                        hbox);
-     gtk_box_pack_start (buttons, edit_btn, 0, 0, 0);
-     gtk_box_pack_start (buttons, delete_btn, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (edit_btn), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (delete_btn), 0, 0, 0);
      
-     gtk_box_pack_start (hbox, label_prefix, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_full_name, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_street, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_city, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_postcode, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_country, 0, 0, 0);
-     gtk_box_pack_end (hbox, buttons, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_prefix), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_full_name), 0, 0, 
0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_street), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_city), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_postcode), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_country), 0, 0, 0);
+     gtk_box_pack_end (GTK_BOX (hbox), GTK_WIDGET (buttons), 0, 0, 0);
 
      if (! is_box)
      {
-          gtk_box_pack_start (vbox, hbox, 0, 0, 0);
+          gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), 0, 0, 0);
      }
 
      gtk_widget_show (GTK_WIDGET (hbox));
@@ -392,8 +408,8 @@ anastasis_gtk_btn_add_auth_post_clicked_cb (GObject *object,
 {
      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_b_post_dialog")));
-     GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_post_dialog_btn_ok");
+     GtkButton *ok_btn = GTK_BUTTON (GCG_get_main_window_object (
+                                        "anastasis_gtk_b_post_dialog_btn_ok"));
      if (g_signal_post > 0)
           g_signal_handler_disconnect (ok_btn, g_signal_post);
      g_signal_post = g_signal_connect(ok_btn, 
@@ -454,12 +470,12 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject 
*object,
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      // set labels
      GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("VIDEO: ");
-     gchar *photo_path = gtk_entry_get_text (
+     const gchar *photo_path = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_video_dialog_photo_path_entry")));
      GtkLabel *label_photo_path = (GtkLabel *) gtk_label_new (photo_path);
 
      // set buttons
-     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
+     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
      GtkButton  *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
      g_signal_connect (edit_btn, 
                        "clicked", 
@@ -470,16 +486,16 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject 
*object,
                        "clicked", 
                        G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
                        hbox);
-     gtk_box_pack_start (buttons, edit_btn, 0, 0, 0);
-     gtk_box_pack_start (buttons, delete_btn, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (edit_btn), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (delete_btn), 0, 0, 0);
      
-     gtk_box_pack_start (hbox, label_prefix, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_photo_path, 0, 0, 0);
-     gtk_box_pack_end (hbox, buttons, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_prefix), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_photo_path), 0, 0, 
0);
+     gtk_box_pack_end (GTK_BOX (hbox), GTK_WIDGET (buttons), 0, 0, 0);
 
      if (! is_box)
      {
-          gtk_box_pack_start (vbox, hbox, 0, 0, 0);
+          gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), 0, 0, 0);
      }
 
      gtk_widget_show (GTK_WIDGET (hbox));
@@ -510,8 +526,8 @@ anastasis_gtk_btn_add_auth_video_clicked_cb (GObject 
*object,
 {
      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_b_video_dialog")));
-     GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_video_dialog_btn_ok");
+     GtkButton *ok_btn = GTK_BUTTON (GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_video_dialog_btn_ok"));
      if (g_signal_video > 0)
           g_signal_handler_disconnect (ok_btn, g_signal_video);
      g_signal_video = g_signal_connect(ok_btn, 
@@ -564,12 +580,12 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject 
*object,
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      // set labels
      GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("SMS: ");
-     gchar *phonenumber = gtk_entry_get_text (
+     const gchar *phonenumber = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_sms_dialog_phonenumber_entry")));
      GtkLabel *label_phonenumber = (GtkLabel *) gtk_label_new (phonenumber);
 
      // set buttons
-     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
+     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
      GtkButton  *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
      g_signal_connect (edit_btn, 
                        "clicked", 
@@ -580,16 +596,16 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject 
*object,
                        "clicked", 
                        G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
                        hbox);
-     gtk_box_pack_start (buttons, edit_btn, 0, 0, 0);
-     gtk_box_pack_start (buttons, delete_btn, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (edit_btn), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (delete_btn), 0, 0, 0);
      
-     gtk_box_pack_start (hbox, label_prefix, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_phonenumber, 0, 0, 0);
-     gtk_box_pack_end (hbox, buttons, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_prefix), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_phonenumber), 0, 0, 
0);
+     gtk_box_pack_end (GTK_BOX (hbox), GTK_WIDGET (buttons), 0, 0, 0);
 
      if (! is_box)
      {
-          gtk_box_pack_start (vbox, hbox, 0, 0, 0);
+          gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), 0, 0, 0);
      }
 
      gtk_widget_show (GTK_WIDGET (hbox));
@@ -620,8 +636,8 @@ anastasis_gtk_btn_add_auth_sms_clicked_cb (GObject *object,
 {
      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_b_sms_dialog")));
-     GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_sms_dialog_btn_ok");
+     GtkButton *ok_btn = GTK_BUTTON (GCG_get_main_window_object (
+                                        "anastasis_gtk_b_sms_dialog_btn_ok"));
      if (g_signal_sms > 0)
           g_signal_handler_disconnect (ok_btn, g_signal_sms);
      g_signal_sms = g_signal_connect(ok_btn, 
@@ -674,12 +690,12 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject 
*object,
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      // set labels
      GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("EMAIL: ");
-     gchar *mailaddress = gtk_entry_get_text (
+     const gchar *mailaddress = gtk_entry_get_text (
           GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_email_dialog_mailaddress_entry")));
      GtkLabel *label_mailaddress = (GtkLabel *) gtk_label_new (mailaddress);
 
      // set buttons
-     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
+     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
      GtkButton  *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
      g_signal_connect (edit_btn, 
                        "clicked", 
@@ -690,16 +706,16 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject 
*object,
                        "clicked", 
                        G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
                        hbox);
-     gtk_box_pack_start (buttons, edit_btn, 0, 0, 0);
-     gtk_box_pack_start (buttons, delete_btn, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (edit_btn), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (buttons), GTK_WIDGET (delete_btn), 0, 0, 0);
      
-     gtk_box_pack_start (hbox, label_prefix, 0, 0, 0);
-     gtk_box_pack_start (hbox, label_mailaddress, 0, 0, 0);
-     gtk_box_pack_end (hbox, buttons, 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_prefix), 0, 0, 0);
+     gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (label_mailaddress), 0, 0, 
0);
+     gtk_box_pack_end (GTK_BOX (hbox), GTK_WIDGET (buttons), 0, 0, 0);
 
      if (! is_box)
      {
-          gtk_box_pack_start (vbox, hbox, 0, 0, 0);
+          gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), 0, 0, 0);
      }
 
      gtk_widget_show (GTK_WIDGET (hbox));
@@ -730,8 +746,8 @@ anastasis_gtk_btn_add_auth_email_clicked_cb (GObject 
*object,
 {
      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_b_email_dialog")));
-     GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_email_dialog_btn_ok");
+     GtkButton *ok_btn = GTK_BUTTON (GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_email_dialog_btn_ok"));
      if (g_signal_email > 0)
           g_signal_handler_disconnect (ok_btn, g_signal_email);
      g_signal_email = g_signal_connect(ok_btn, 
@@ -770,12 +786,12 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
 {
      GList *children, *iter;
      children = gtk_container_get_children (GTK_CONTAINER (user_data));
-     char *type;
+     char *type = "";
      unsigned int index = 0;
      for (iter = children; iter != NULL; iter = g_list_next (iter))
      {
-          gchar *text;
-          gchar *widget_name = gtk_widget_get_name (GTK_WIDGET (iter->data));
+          const gchar *text = "";
+          const gchar *widget_name = gtk_widget_get_name (GTK_WIDGET 
(iter->data));
           if (0 == strcmp (widget_name, "GtkLabel"))
           {
                text = gtk_label_get_text (GTK_LABEL (iter->data));
@@ -801,8 +817,8 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
                     {
                          gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_question_dialog_answer_entry")), text);
-                         GtkButton *ok_btn = GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_question_dialog_btn_ok");
+                         GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_question_dialog_btn_ok"));
                          if (g_signal_question > 0)
                               g_signal_handler_disconnect (ok_btn, 
g_signal_question);
                          g_signal_question = g_signal_connect(ok_btn, 
@@ -822,8 +838,8 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
                     {
                          gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_sms_dialog_phonenumber_entry")), text);
-                         GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_sms_dialog_btn_ok");
+                         GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
+                                        "anastasis_gtk_b_sms_dialog_btn_ok"));
                          if (g_signal_sms > 0)
                               g_signal_handler_disconnect (ok_btn, 
g_signal_sms);
                          g_signal_sms = g_signal_connect (ok_btn, 
@@ -842,8 +858,8 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
                     {
                          gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_email_dialog_mailaddress_entry")), text);
-                         GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_email_dialog_btn_ok");
+                         GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_email_dialog_btn_ok"));
                          if (g_signal_email > 0)
                               g_signal_handler_disconnect (ok_btn, 
g_signal_email);
                          g_signal_email = g_signal_connect (ok_btn, 
@@ -874,8 +890,8 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
                     {
                          gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_post_dialog_country_entry")), text);
-                         GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_post_dialog_btn_ok");
+                         GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
+                                        "anastasis_gtk_b_post_dialog_btn_ok"));
                          if (g_signal_post > 0)
                               g_signal_handler_disconnect (ok_btn, 
g_signal_post);
                          g_signal_post = g_signal_connect (ok_btn, 
@@ -894,8 +910,8 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
                     {
                          gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_video_dialog_photo_path_entry")), text);
-                         GtkButton *ok_btn = GCG_get_main_window_object (
-                                        "anastasis_gtk_b_video_dialog_btn_ok");
+                         GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_video_dialog_btn_ok"));
                          if (g_signal_video > 0)
                               g_signal_handler_disconnect (ok_btn, 
g_signal_video);
                          g_signal_video = g_signal_connect (ok_btn, 
@@ -922,17 +938,17 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
  * @param http_status HTTP status of the request
  * @param methods supported methods by this provider
  * @param annual_fee Annual fee of this service
- * @param question_cost Cost for authentication by question
  */
 static void
 config_cb (void *cls,
            unsigned int http_status,
-           const char *methods,
+           const json_t *methods,
            const char *conf_currency,
-           const struct TALER_Amount *annual_fee,
-           const struct TALER_Amount *question_cost)
+           const struct TALER_Amount *annual_fee)
 {
-     json_t *auth_method = json_object ();
+     json_t *method;
+     json_t *method_arr;
+     size_t index;
      struct ConfigState *cs = cls;
 
      cs->co = NULL;
@@ -946,64 +962,210 @@ config_cb (void *cls,
                          http_status,
                          __FILE__,
                          __LINE__);
-          //return;
-     }
-     if (NULL != strstr (methods, "question"))
-     {
-          gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                        
"anastasis_gtk_btn_add_auth_question")));
-     }
-     if (NULL != strstr (methods, "sms"))
-     {
-          gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                        "anastasis_gtk_btn_add_auth_sms")));
+          return;
      }
-     if (NULL != strstr (methods, "email"))
+     cs->server->backend_methods = methods;
+     cs->server->backend_cost = *annual_fee;
+     cs->server->backend_currency = GNUNET_malloc (strlen (conf_currency));
+     GNUNET_strlcpy (cs->server->backend_currency,
+                     conf_currency,
+                     strlen (conf_currency));
+     method_arr = json_object_get (methods, "methods");
+     json_array_foreach (method_arr, index, method)
      {
-          gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                        "anastasis_gtk_btn_add_auth_email")));
-     }
-     if (NULL != strstr (methods, "video"))
-     {
-          gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                        "anastasis_gtk_btn_add_auth_video")));
+          const char *method_str = json_string_value (
+               json_object_get (method, "method"));
+          if (method_str)
+          {
+               char *widget;
+               GNUNET_asprintf (&widget,
+                                "anastasis_gtk_btn_add_auth_%s",
+                                method_str);
+               gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                             widget)));
+          }
      }
-     if (NULL != strstr (methods, "post"))
+}
+
+
+/**
+ * Initialize the auhentication methods in backup mode.
+ * 
+ * @param state the state to operate on
+ */
+void
+init_b_policy (json_t *state)
+{
+     GList *children, *iter;
+     json_t *arguments = json_object ();
+     json_t *argument_arr = json_array ();
+     children = gtk_container_get_children (GTK_CONTAINER 
(GCG_get_main_window_object (
+                                                                    
"anastasis_gtk_b_authentication_vbox")));
+     for (iter = children; iter != NULL; iter = g_list_next (iter))
      {
-          gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                        "anastasis_gtk_btn_add_auth_post")));
+          GList *grandchildren, *inner_iter;
+          grandchildren = gtk_container_get_children (GTK_CONTAINER 
(iter->data));
+          json_t *argument = json_object ();
+          json_t *provider_arr = json_array ();
+          unsigned int index = 0;
+          if (GTK_IS_BOX (iter->data))
+               for (inner_iter = grandchildren; inner_iter != NULL; inner_iter 
= g_list_next (inner_iter))
+               {
+                    // iterate over hbox children
+                    if (GTK_IS_LABEL (inner_iter->data))
+                    {
+                         const char *text = gtk_label_get_text (GTK_LABEL 
(inner_iter->data));
+
+                         // check method type
+                         if (index == 0)
+                         {
+                              if (0 == strcmp (text, "Q: "))
+                                   json_object_set_new (argument, "method", 
json_string ("question"));
+                              else if (0 == strcmp (text, "EMAIL: "))
+                                   json_object_set_new (argument, "method", 
json_string ("email"));
+                              else if (0 == strcmp (text, "SMS: "))
+                                   json_object_set_new (argument, "method", 
json_string ("sms"));
+                              else if (0 == strcmp (text, "POST: "))
+                                   json_object_set_new (argument, "method", 
json_string ("post"));
+                              else if (0 == strcmp (text, "VIDEO: "))
+                                   json_object_set_new (argument, "method", 
json_string ("video"));
+                         }
+
+                         // check method attributes
+                         if (index == 1)
+                         {
+                              const char *method_type = json_string_value 
(json_object_get (argument, "method"));
+                              if (0 == strcmp (method_type, "question"))
+                                   json_object_set_new (argument, "question", 
json_string (text));
+                              else if (0 == strcmp (method_type, "email"))
+                                   json_object_set_new (argument, 
"email_address", json_string (text));
+                              else if (0 == strcmp (method_type, "sms"))
+                                   json_object_set_new (argument, 
"phone_number", json_string (text));
+                              else if (0 == strcmp (method_type, "post"))
+                                   json_object_set_new (argument, "full_name", 
json_string (text));
+                              else if (0 == strcmp (method_type, "video"))
+                                   json_object_set_new (argument, 
"path_picture", json_string (text));
+                         }
+
+                         if (index == 2)
+                         {
+                              const char *method_type = json_string_value 
(json_object_get (argument, "method"));
+                              if (0 == strcmp (method_type, "question"))
+                                   json_object_set_new (argument, "answer", 
json_string (text));
+                              else if (0 == strcmp (method_type, "post"))
+                                   json_object_set_new (argument, "street", 
json_string (text));
+                         }
+
+                         if (index == 3)
+                         {
+                              const char *method_type = json_string_value 
(json_object_get (argument, "method"));
+                              if (0 == strcmp (method_type, "post"))
+                                   json_object_set_new (argument, "city", 
json_string (text));
+                         }
+
+                         if (index == 4)
+                         {
+                              const char *method_type = json_string_value 
(json_object_get (argument, "method"));
+                              if (0 == strcmp (method_type, "post"))
+                                   json_object_set_new (argument, "postcode", 
json_string (text));
+                         }
+
+                         if (index == 5)
+                         {
+                              const char *method_type = json_string_value 
(json_object_get (argument, "method"));
+                              if (0 == strcmp (method_type, "post"))
+                                   json_object_set_new (argument, "country", 
json_string (text));
+                         }
+                    }
+                    index++;
+               }
+          const char *method_type = json_string_value (json_object_get 
(argument, "method"));
+          for (unsigned int i = 0; i < servers_length; i++)
+          {
+               size_t index2;
+               json_t *method;
+               json_t *method_arr = json_object_get 
(servers[i].backend_methods, "methods");
+               json_array_foreach (method_arr, index2, method)
+               {
+                    if (0 == strcmp (method_type, 
+                                     json_string_value (json_object_get 
(method, "method"))))
+                    {
+                         const char *method_cost = json_string_value 
(json_object_get (method, "cost"));
+                         json_t *provider = json_pack ("{s:s, s:s, s:s, s:s, 
s:s, s:o}",
+                                                       "provider-id", 
servers[i].backend_id,
+                                                       "provider-url", 
servers[i].backend_url,
+                                                       "provider-name", 
servers[i].backend_name,
+                                                       "currency", 
servers[i].backend_currency,
+                                                       "method_cost", 
method_cost,
+                                                       "annual_cost", 
+                                                       TALER_JSON_from_amount 
(&servers[i].backend_cost));
+                         json_array_append_new (provider_arr, provider);
+                         break;
+                    }
+               }
+          }
+          json_object_set_new (argument, "providers", provider_arr);
+          json_array_append_new (argument_arr, argument);
+          g_list_free (grandchildren);
      }
+     g_list_free (children);
+     json_object_set_new (arguments, "authentication_methods", argument_arr);
+     ANASTASIS_redux_action (state,
+                             "adding_authentication",
+                             arguments,
+                             &action_cb,
+                             NULL);
 }
 
 
 /**
- * Initialize the auhentication methods.
+ * Initialize the auhentication methods in backup mode.
  * 
- * @param state the initial state to get the continents from
+ * @param state the state to operate on
  */
 void
-init_auth_methods (json_t *state)
+init_b_auth_methods (json_t *state)
 {
-    size_t index;
-    json_t *provider;
-    json_t *provider_list = json_object_get (state, "provider-list");
+     size_t index;
+     json_t *provider;
+     json_t *provider_list = json_object_get (state, "provider-list");
 
-    json_array_foreach (provider_list, index, provider)
-    {
-          struct ConfigState *cs = GNUNET_new (struct ConfigState);
+     json_array_foreach (provider_list, index, provider)
+     {
+          struct ServerInfo *server = GNUNET_new (struct ServerInfo);
           const char *url = json_string_value (json_object_get (provider, 
"provider-url"));
+          const char *provider_name = json_string_value (json_object_get 
(provider, "provider-name"));
+          const char *provider_id = json_string_value (json_object_get 
(provider, "provider-id"));
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      "Url is: %s\n", url);
+                    "Url is: %s\n", url);
+          server->backend_url = GNUNET_malloc (strlen (url) + 1);
+          GNUNET_strlcpy (server->backend_url,
+                          url,
+                          strlen (url) + 1);
+          server->backend_name = GNUNET_malloc (strlen (provider_name) + 1);
+          GNUNET_strlcpy (server->backend_name,
+                          provider_name,
+                          strlen (provider_name) + 1);
+          server->backend_id = GNUNET_malloc (strlen (provider_id) + 1);
+          GNUNET_strlcpy (server->backend_id,
+                          provider_id,
+                          strlen (provider_id) + 1);
+          GNUNET_array_append (servers, servers_length, *server);
+     }
+     for (unsigned int i = 0; i < servers_length; i++)
+     {
+          struct ConfigState *cs = GNUNET_new (struct ConfigState);
+          cs->server = &servers[i];
           cs->http_status = MHD_HTTP_OK;
           cs->co = ANASTASIS_get_config (ctx,
-                                         url,
+                                         servers[i].backend_url,
                                          config_cb,
                                          cs);
           if (NULL == cs->co)
           {
           /** FIXME: Error handling */
           }
-    }
+     }
 }
 
 
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index 4eb0788..3df08af 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -28,7 +28,7 @@
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet-gtk/gnunet_gtk.h>
 #include <gtk/gtk.h>
-#include "anastasis-gtk_helper.h"
+#include <anastasis-gtk/anastasis-gtk_helper.h>
 #include <jansson.h>
 
 
@@ -187,9 +187,9 @@ action_cb (void *cls,
         {
             if (json_object_get (redux_state, "backup-state"))
             {
-                init_auth_methods (redux_state);
                 gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_b_authentication_frame")));
+                init_b_auth_methods (redux_state);
                 gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                                 
"anastasis_gtk_b_authentication_methods_image")));
             }
@@ -309,7 +309,7 @@ init_id_attr (json_t *state,
     {
         const char *widget_name = json_string_value (json_object_get (id_attr, 
"widget"));
         const char *attr_type = json_string_value (json_object_get (id_attr, 
"type"));
-        const char *attr_name = json_string_value (json_object_get (id_attr, 
"name"));
+        //const char *attr_name = json_string_value (json_object_get (id_attr, 
"name"));
         const char *attr_label = json_string_value (json_object_get (id_attr, 
"label"));
         
         if (widget_name)
diff --git a/src/include/anastasis-gtk_helper.h 
b/src/include/anastasis-gtk_helper.h
index c1f384f..7bcd44e 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -26,6 +26,7 @@
  */
 
 #include <gnunet-gtk/gnunet_gtk.h>
+#include <gtk/gtk.h>
 #include <anastasis/anastasis_service.h>
 #include <anastasis/anastasis_redux.h>
 
@@ -140,12 +141,21 @@ init_id_attr (json_t *state,
 
 
 /**
- * Initialize the auhentication methods.
+ * Initialize the auhentication methods in backup mode.
  * 
- * @param state the initial state to get the continents from
+ * @param state the state to operate on
  */
 void
-init_auth_methods (json_t *state);
+init_b_auth_methods (json_t *state);
+
+
+/**
+ * Initialize the policies in backup mode.
+ * 
+ * @param state the state to operate on
+ */
+void
+init_b_policy (json_t *state);
 
 
 /**

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