[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] 01/05: worked on authentication_frame
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] 01/05: worked on authentication_frame |
Date: |
Wed, 23 Sep 2020 19:02:51 +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 a8bfe2ca6efe097de9ce8aca2b2b69f2e821336e
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Sep 21 12:04:03 2020 +0200
worked on authentication_frame
---
src/anastasis/Makefile.am | 4 +-
src/anastasis/anastasis-gtk.c | 14 ++++
src/anastasis/anastasis-gtk_backup.c | 155 +++++++++++++++++++++++++++++++++++
src/anastasis/anastasis-gtk_helper.c | 15 ++--
src/include/anastasis-gtk_helper.h | 20 +++++
5 files changed, 202 insertions(+), 6 deletions(-)
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index be38f24..56d9ca9 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -20,10 +20,12 @@ anastasis_gtk_SOURCES = \
anastasis_gtk_LDADD = \
@GTK_LIBS@ \
@GLADE_LIBS@ @GNUNET_LIBS@ \
- -lanastasisredux \
-lgnunetgtk \
-lgnunetutil \
+ -lgnunetcurl \
-ljansson \
+ -lanastasisrest \
+ -lanastasisredux \
$(INTLLIBS)
anastasis_gtk_LDFLAGS = \
-export-dynamic
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 18ab3ab..5c9356c 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -40,6 +40,16 @@ struct GNUNET_GTK_MainLoop *ml;
*/
struct GNUNET_CONFIGURATION_Handle *cfg;
+/**
+ * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+struct GNUNET_CURL_RescheduleContext *rc;
+
+/**
+ * Curl context for communication with taler backend
+ */
+struct GNUNET_CURL_Context *ctx;
+
/**
* Actual state.
*/
@@ -101,6 +111,10 @@ run (void *cls)
gtk_window_present (GTK_WINDOW (main_window));
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
NULL);
+ /* initialize HTTP client */
+ ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
+ &rc);
+ rc = GNUNET_CURL_gnunet_rc_create (ctx);
}
diff --git a/src/anastasis/anastasis-gtk_backup.c
b/src/anastasis/anastasis-gtk_backup.c
index 7046f43..a65c402 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -32,6 +32,69 @@
#include <jansson.h>
+/**
+ * Server information
+ */
+struct ServerInfo
+{
+ /**
+ * URL of the anastasis backend.
+ */
+ char *backend_url;
+
+ /**
+ * label of the anastasis backend.
+ */
+ const char *backend_label;
+
+ /**
+ * supported methods of the anastasis backend.
+ */
+ char *backend_methods;
+
+ /**
+ * server salt of the anastasis backend.
+ */
+ const struct ANASTASIS_CRYPTO_PowSalt *backend_salt;
+
+ /**
+ * insurance of the anastasis backend.
+ */
+ const struct TALER_Amount *backend_insurance;
+
+ /**
+ * cost of using the anastasis backend.
+ */
+ const struct TALER_Amount *backend_cost;
+
+ /**
+ * user identifier derived from user data and backend salt
+ */
+ struct ANASTASIS_CRYPTO_UserIdentifierP *user_id;
+};
+
+/**
+ * State for a "get config" CMD.
+ */
+struct ConfigState
+{
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status;
+
+ /**
+ * The /config GET operation handle.
+ */
+ struct ANASTASIS_ConfigOperation *co;
+
+ /**
+ * Reference to a ServerInfo.
+ */
+ struct ServerInfo *server;
+};
+
+
/**
* Callback invoked if the the "backup"-button is clicked.
*
@@ -59,3 +122,95 @@ anastasis_gtk_backup_button_clicked (GObject *object,
}
+/**
+ * Function called with the results of a #ANASTASIS_get_config().
+ *
+ * @param cls closure
+ * @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 char *conf_currency,
+ const struct TALER_Amount *annual_fee,
+ const struct TALER_Amount *question_cost)
+{
+ json_t *auth_method = json_object ();
+ struct ConfigState *cs = cls;
+
+ cs->co = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d url is %s\n", __FILE__, __LINE__,
+ cs->server->backend_url);
+ if (http_status != cs->http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u in %s:%u\n",
+ http_status,
+ __FILE__,
+ __LINE__);
+ //return;
+ }
+ if (NULL != strstr (methods, "question"))
+ {
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_bttn_add_auth_question")));
+ }
+ if (NULL != strstr (methods, "sms"))
+ {
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_bttn_add_auth_sms")));
+ }
+ if (NULL != strstr (methods, "email"))
+ {
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_bttn_add_auth_email")));
+ }
+ if (NULL != strstr (methods, "video"))
+ {
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_bttn_add_auth_video")));
+ }
+ if (NULL != strstr (methods, "post"))
+ {
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_bttn_add_auth_post")));
+ }
+}
+
+
+/**
+ * Initialize the auhentication methods.
+ *
+ * @param state the initial state to get the continents from
+ */
+void
+init_auth_methods (json_t *state)
+{
+ 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);
+ const char *url = json_string_value (json_object_get (provider,
"provider-url"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Url is: %s\n", url);
+ cs->http_status = MHD_HTTP_OK;
+ cs->co = ANASTASIS_get_config (ctx,
+ 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 1b9b6b6..a5235de 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -177,14 +177,19 @@ action_cb (void *cls,
"anastasis_gtk_main_window_forward_button")), true);
init_id_attr (redux_state, json_string_value (json_object_get
(redux_state, "selected_country")));
}
-
+ if (check_state (redux_state, "ReduxUserAttributesAddedState"))
+ {
+ init_auth_methods (redux_state);
+ }
+ /** FIXME: Don't use this like this */
if (0 == persist_state (redux_state))
return;
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to persist new state! \n");
}
- GNUNET_SCHEDULER_shutdown ();
+ /** FIXME: see above
+ * GNUNET_SCHEDULER_shutdown (); */
}
@@ -590,9 +595,9 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
for (iter = children; iter != NULL; iter = g_list_next (iter))
{
bool isset = false;
- const char *entry_widget;
- const char *cal_widget;
- const char *widget = gtk_buildable_get_name (iter->data);
+ char *entry_widget;
+ char *cal_widget;
+ char *widget = gtk_buildable_get_name (iter->data);
json_t *id_attr = json_object ();
GNUNET_asprintf (&entry_widget,
diff --git a/src/include/anastasis-gtk_helper.h
b/src/include/anastasis-gtk_helper.h
index d2e1aab..a1510f5 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 <anastasis/anastasis_service.h>
#include <anastasis/anastasis_redux.h>
/**
@@ -43,6 +44,16 @@ extern struct GNUNET_CONFIGURATION_Handle *cfg;
*/
extern json_t *redux_state;
+/**
+ * Curl context for communication with taler backend
+ */
+extern struct GNUNET_CURL_Context *ctx;
+
+/**
+ * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+extern struct GNUNET_CURL_RescheduleContext *rc;
+
/**
* Function called with the results of #ANASTASIS_backup_action
@@ -119,6 +130,15 @@ init_id_attr (json_t *state,
const char *country);
+/**
+ * Initialize the auhentication methods.
+ *
+ * @param state the initial state to get the continents from
+ */
+void
+init_auth_methods (json_t *state);
+
+
/**
* Callback invoked if the the "back"-button is clicked.
*
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis-gtk] branch master updated (d6961fe -> 095cb09), gnunet, 2020/09/23
- [taler-anastasis-gtk] 04/05: worked on adding authentication methods, gnunet, 2020/09/23
- [taler-anastasis-gtk] 01/05: worked on authentication_frame,
gnunet <=
- [taler-anastasis-gtk] 03/05: worked on illustrations and authentication frame, gnunet, 2020/09/23
- [taler-anastasis-gtk] 02/05: worked on authentication_frame, added illustration, gnunet, 2020/09/23
- [taler-anastasis-gtk] 05/05: worked on authentication_frame, add methods, edit methods, delete methods, gnunet, 2020/09/23