[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] 02/03: serialize authentication methods
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] 02/03: serialize authentication methods |
Date: |
Mon, 28 Sep 2020 15:19:49 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis-gtk.
commit 6278d34c80ff2d78a967d9442567901b0bbae859
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Sep 28 09:32:03 2020 +0200
serialize authentication methods
---
src/anastasis/anastasis-gtk.c | 13 ++++--
src/anastasis/anastasis-gtk_backup.c | 88 +++++++++++++++++++++++++++++++++++-
2 files changed, 97 insertions(+), 4 deletions(-)
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 7c21f8f..c8a713b 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -475,13 +475,20 @@ 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"))))
{
if (check_state (redux_state, "ReduxUserAttributesAddedState"))
- init_b_policy (redux_state);
- }*/
+ {
+ 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 4e7b3ed..9a48948 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -978,7 +978,93 @@ config_cb (void *cls,
void
init_b_policy (json_t *state)
{
- json_t *arguments;
+ 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))
+ {
+ GList *grandchildren, *inner_iter;
+ grandchildren = gtk_container_get_children (GTK_CONTAINER
(iter->data));
+ json_t *argument = json_object ();
+ 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++;
+ }
+ 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,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.