gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated (2af3228 -> 421995e)


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated (2af3228 -> 421995e)
Date: Mon, 12 Oct 2020 20:34:55 +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 2af3228  fix config api request
     new 4f15a32  fix authentication_providers building
     new 9340c49  fix method button showing
     new 1fcb59d  fix method deletion
     new ca10218  fix method deletion
     new 421995e  fix method edit button

The 5 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/anastasis-gtk_backup.c | 151 +++++++++++++++++++++++++++--------
 src/anastasis/anastasis-gtk_helper.c |  10 +--
 2 files changed, 123 insertions(+), 38 deletions(-)

diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index 485f1b6..14eca7b 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -37,7 +37,81 @@ guint g_signal_email;
 guint g_signal_post;
 guint g_signal_video;
 
-     
+
+/**
+ * Delete method from hbox.
+ * 
+ * @param user_data pointer to hbox containing method
+ */ 
+static void
+delete_auth_method (gpointer user_data)
+{
+     if (GTK_IS_BOX (user_data))
+     {
+          GList *user_data_children, *iter;
+          user_data_children = gtk_container_get_children (GTK_CONTAINER 
(user_data));
+          
+          // parse state to delete method
+          if (NULL != user_data_children)
+          {
+               const gchar *label;
+               json_t *arguments = json_object ();
+               GNUNET_assert (NULL != arguments);
+               json_t *method = json_object ();
+               GNUNET_assert (NULL != method);
+               json_t *value = json_object ();
+               GNUNET_assert (NULL != value);
+               unsigned int index = 0;
+
+               for (iter = user_data_children; iter != NULL; iter = 
g_list_next (iter))
+               {
+                    if (GTK_IS_LABEL (iter->data))
+                    {
+                         label= gtk_label_get_text (GTK_LABEL (iter->data));
+
+                         if (index == 0)
+                         {
+                              char *method_type = NULL;
+                              if (0 == strcmp ("Q: ", label))
+                                    method_type = "question";
+                              if (0 == strcmp ("SMS: ", label))
+                                   method_type = "sms";
+                              if (0 == strcmp ("VIDEO: ", label))
+                                   method_type = "video";
+                              if (0 == strcmp ("POST: ", label))
+                                   method_type = "post";
+                              if (0 == strcmp ("EMAIL: ", label))
+                                   method_type = "email";
+
+                              GNUNET_assert (0 == json_object_set_new (method,
+                                                                       
"method",
+                                                                       
json_string (method_type)));
+                         }
+                         if (index == 1)
+                         {
+                              GNUNET_assert (0 == json_object_set_new (method,
+                                                                       "value",
+                                                                       
json_string (label)));
+                              GNUNET_assert (0 == json_object_set_new 
(arguments,
+                                                                       
"authentication_method",
+                                                                       
method));
+                              ANASTASIS_redux_action (redux_state,
+                                                      "delete_authentication",
+                                                      arguments,
+                                                      &action_cb,
+                                                      NULL,
+                                                      NULL);
+                         }
+                         index++;
+                    }
+                    gtk_widget_destroy (iter->data);
+               }
+          }
+          g_list_free (user_data_children);
+     }
+}
+
+
 /**
  * Callback invoked if the the "authentication methods edit"-button is clicked.
  *
@@ -101,15 +175,15 @@ void
 anastasis_gtk_b_auth_method_btn_delete_clicked_cb (GObject *object,
                                                    gpointer user_data)
 {
-     GList *children;
-     gtk_widget_destroy (GTK_WIDGET (user_data));
+     delete_auth_method (user_data);
 
-     children = gtk_container_get_children (GTK_CONTAINER 
(GCG_get_main_window_object (
+     // if no methods, set sensitivity of forward button to false
+     GList *vbox_children = gtk_container_get_children (GTK_CONTAINER 
(GCG_get_main_window_object (
                                                                  
"anastasis_gtk_b_authentication_vbox")));
-     if (! children)
+     if (NULL == vbox_children)
           gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_main_window_forward_button")), false);   
-     g_list_free (children);
+     g_list_free (vbox_children);
 }
 
 
@@ -131,10 +205,8 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb (GObject 
*object,
      if (is_box)
      {
           hbox = (GtkHBox *) user_data;
-          GList *children, *iter;
-          children = gtk_container_get_children (GTK_CONTAINER (user_data));
-          for (iter = children; iter != NULL; iter = g_list_next (iter))
-               gtk_widget_destroy (iter->data);
+          // if is_box is true, we are editing and have to delete the old 
method
+          delete_auth_method (user_data);
      }
      else
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -153,11 +225,11 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb 
(GObject *object,
           json_t *auth_method = json_object ();
           json_t *method_data = json_object ();
 
-          json_object_set_new (auth_method, "method", json_string 
("question"));
-          json_object_set_new (method_data, "question", json_string 
(question));
-          json_object_set_new (method_data, "answer", json_string (answer));
-          json_object_set_new (auth_method, "data", method_data);
-          json_object_set_new (arguments, "authentication_method", 
method_data);
+          GNUNET_assert (0 == json_object_set_new (auth_method, "method", 
json_string ("question")));
+          GNUNET_assert (0 == json_object_set_new (method_data, "question", 
json_string (question)));
+          GNUNET_assert (0 == json_object_set_new (method_data, "answer", 
json_string (answer)));
+          GNUNET_assert (0 == json_object_set_new (auth_method, "data", 
method_data));
+          GNUNET_assert (0 ==  json_object_set_new (arguments, 
"authentication_method", auth_method));
 
           ANASTASIS_redux_action (redux_state,
                                   "add_authentication",
@@ -270,10 +342,8 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject 
*object,
      if (is_box)
      {
           hbox = (GtkHBox *) user_data;
-          GList *children, *iter;
-          children = gtk_container_get_children (GTK_CONTAINER (user_data));
-          for (iter = children; iter != NULL; iter = g_list_next (iter))
-               gtk_widget_destroy (iter->data);
+          // if is_box is true, we are editing and have to delete the old 
method
+          delete_auth_method (user_data);
      }
      else
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -438,10 +508,8 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject 
*object,
      if (is_box)
      {
           hbox = (GtkHBox *) user_data;
-          GList *children, *iter;
-          children = gtk_container_get_children (GTK_CONTAINER (user_data));
-          for (iter = children; iter != NULL; iter = g_list_next (iter))
-               gtk_widget_destroy (iter->data);
+          // if is_box is true, we are editing and have to delete the old 
method
+          delete_auth_method (user_data);
      }
      else
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -566,10 +634,8 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject 
*object,
      if (is_box)
      {
           hbox = (GtkHBox *) user_data;
-          GList *children, *iter;
-          children = gtk_container_get_children (GTK_CONTAINER (user_data));
-          for (iter = children; iter != NULL; iter = g_list_next (iter))
-               gtk_widget_destroy (iter->data);
+          // if is_box is true, we are editing and have to delete the old 
method
+          delete_auth_method (user_data);
      }
      else
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -694,10 +760,8 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject 
*object,
      if (is_box)
      {
           hbox = (GtkHBox *) user_data;
-          GList *children, *iter;
-          children = gtk_container_get_children (GTK_CONTAINER (user_data));
-          for (iter = children; iter != NULL; iter = g_list_next (iter))
-               gtk_widget_destroy (iter->data);
+          // if is_box is true, we are editing and have to delete the old 
method
+          delete_auth_method (user_data);
      }
      else
           hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -1147,7 +1211,30 @@ init_b_policy (json_t *state)
 void
 init_b_auth_methods (json_t *state)
 {
-     
+     json_t *providers = json_object_get (state, "authentication_providers");
+     if (NULL != providers)
+     {
+          const char *method;
+          json_t *value;
+
+          json_object_foreach(providers, method, value) {
+               if (0 == strcmp (method, "question"))
+                    gtk_widget_show (GTK_WIDGET (
+                         GCG_get_main_window_object 
("anastasis_gtk_btn_add_auth_question")));
+               if (0 == strcmp (method, "sms"))
+                    gtk_widget_show (GTK_WIDGET (
+                         GCG_get_main_window_object 
("anastasis_gtk_btn_add_auth_sms")));
+               if (0 == strcmp (method, "video"))
+                    gtk_widget_show (GTK_WIDGET (
+                         GCG_get_main_window_object 
("anastasis_gtk_btn_add_auth_video")));
+               if (0 == strcmp (method, "email"))
+                    gtk_widget_show (GTK_WIDGET (
+                         GCG_get_main_window_object 
("anastasis_gtk_btn_add_auth_email")));
+               if (0 == strcmp (method, "post"))
+                    gtk_widget_show (GTK_WIDGET (
+                         GCG_get_main_window_object 
("anastasis_gtk_btn_add_auth_post")));
+          }
+     }
 }
 
 
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index 7060165..be6c94a 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -315,11 +315,12 @@ action_cb (void *cls,
                 json_t *value;
 
                 // update authentication_providers
-                /** FIXME: authentication methods is update wrongly here!!! */
+                json_t *methods = json_object_get (providers, 
"authentication_providers");
                 GNUNET_assert (0 == 
-                               json_object_update_recursive (providers,
+                               json_object_update_recursive (methods,
                                                              json_object_get 
(response,
                                                                               
"config")));
+
                 // delete this provider from missing_providers
                 json_t *provider_id = json_object_get (response, "provider");
                 json_array_foreach (missing_providers, index, value)
@@ -333,9 +334,6 @@ action_cb (void *cls,
                     }
                 }
             }
-            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                        "PROVIDERS:  %s\n\n",
-                        json_dumps (providers, JSON_COMPACT));
         }
         else
         {
@@ -379,9 +377,9 @@ action_cb (void *cls,
                     anastasis_gtk_hide_all_frames ();
                     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")));
+                    init_b_auth_methods (redux_state);
                 }
             }
             if (check_state (redux_state, PoliciesReviewingState)

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