summaryrefslogtreecommitdiff
path: root/src/anastasis
diff options
context:
space:
mode:
Diffstat (limited to 'src/anastasis')
-rw-r--r--src/anastasis/anastasis-gtk_action.c66
-rw-r--r--src/anastasis/anastasis-gtk_attributes.c6
-rw-r--r--src/anastasis/anastasis-gtk_handle-auth-delete-button-clicked.c6
-rw-r--r--src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c6
-rw-r--r--src/anastasis/anastasis-gtk_handle-challenge-code.c6
-rw-r--r--src/anastasis/anastasis-gtk_handle-challenge-question.c6
-rw-r--r--src/anastasis/anastasis-gtk_handle-challenge-row-activated.c7
-rw-r--r--src/anastasis/anastasis-gtk_handle-continent-selected.c7
-rw-r--r--src/anastasis/anastasis-gtk_handle-core-secret-changed.c2
-rw-r--r--src/anastasis/anastasis-gtk_handle-core-secret-name-changed.c7
-rw-r--r--src/anastasis/anastasis-gtk_handle-expiration-change.c7
-rw-r--r--src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c12
-rw-r--r--src/anastasis/anastasis-gtk_handle-method-post.c33
-rw-r--r--src/anastasis/anastasis-gtk_handle-policy-version-changed.c11
-rw-r--r--src/anastasis/anastasis-gtk_pe-delete-challenge.c18
-rw-r--r--src/anastasis/anastasis-gtk_pe-delete-policy.c14
-rw-r--r--src/anastasis/anastasis-gtk_pe-edit-policy.c295
17 files changed, 254 insertions, 255 deletions
diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c
index f0c28c3..0e929f9 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -844,7 +844,7 @@ lookup_recovery_cost (const char *provider,
const char *mtype;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any ("usage_fee",
- &fee),
+ &fee),
GNUNET_JSON_spec_string ("type",
&mtype),
GNUNET_JSON_spec_end ()
@@ -1137,7 +1137,7 @@ action_secret_editing (void)
{
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any ("fee",
- &a),
+ &a),
GNUNET_JSON_spec_end ()
};
char *tmp;
@@ -1174,16 +1174,16 @@ action_secret_editing (void)
if (is_free)
GNUNET_assert (sizeof (estr) >
- strftime (estr,
- sizeof (estr),
- "%d %B %Y",
- &tv));
+ strftime (estr,
+ sizeof (estr),
+ "%d %B %Y",
+ &tv));
else
GNUNET_assert (sizeof (estr) >
- strftime (estr,
- sizeof (estr),
- "%d %B",
- &tv));
+ strftime (estr,
+ sizeof (estr),
+ "%d %B",
+ &tv));
update_label ("expiration_date_without_year_label",
estr);
}
@@ -1516,9 +1516,9 @@ action_truths_paying (void)
timeout = GNUNET_TIME_UNIT_MINUTES;
GNUNET_assert (NULL == AG_ra);
- args = json_pack ("{s:o}",
- "timeout",
- GNUNET_JSON_from_time_rel (timeout));
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_time_rel ("timeout",
+ timeout));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"pay",
args,
@@ -1599,9 +1599,9 @@ action_policies_paying (void)
timeout = GNUNET_TIME_UNIT_MINUTES;
GNUNET_assert (NULL == AG_ra);
- args = json_pack ("{s:o}",
- "timeout",
- GNUNET_JSON_from_time_rel (timeout));
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_time_rel ("timeout",
+ timeout));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"pay",
args,
@@ -1685,7 +1685,7 @@ action_backup_finished (void)
/* be more conservative in what we show */
mexp = GNUNET_TIME_absolute_subtract (mexp,
- GNUNET_TIME_UNIT_DAYS);
+ GNUNET_TIME_UNIT_DAYS);
t = mexp.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
GNUNET_assert (NULL !=
localtime_r (&t,
@@ -1696,7 +1696,7 @@ action_backup_finished (void)
"%d %B %Y",
&tv));
update_label ("backup_expiration_date_label",
- GNUNET_STRINGS_absolute_time_to_string (mexp));
+ GNUNET_STRINGS_absolute_time_to_string (mexp));
}
AG_hide ("anastasis_gtk_progress_vbox");
AG_hide ("anastasis_gtk_backup_progress_scrolled_window");
@@ -2282,7 +2282,7 @@ action_challenge_selecting (void)
AG_CSM_NOT_SOLVED, true,
AG_CSM_TYPE, type,
AG_CSM_INSTRUCTIONS, instructions,
- AG_CSM_PROVIDER_URL, provider,
+ AG_CSM_PROVIDER_URL, provider,
-1);
}
}
@@ -2328,7 +2328,7 @@ action_challenge_selecting (void)
const char *type;
const char *provider;
const char *instructions;
- bool solved = false;
+ bool solved = false;
struct GNUNET_JSON_Specification cspec[] = {
GNUNET_JSON_spec_string ("type",
&type),
@@ -2336,9 +2336,9 @@ action_challenge_selecting (void)
&provider),
GNUNET_JSON_spec_string ("instructions",
&instructions),
- GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_bool ("solved",
- &solved)),
+ &solved)),
GNUNET_JSON_spec_end ()
};
struct TALER_Amount recovery_cost;
@@ -2382,8 +2382,8 @@ action_challenge_selecting (void)
TALER_amount2s (&recovery_cost),
AG_PRMC_PROVIDER_URL,
provider,
- AG_PRMC_WAS_SOLVED,
- solved,
+ AG_PRMC_WAS_SOLVED,
+ solved,
-1);
if (NULL == summary)
{
@@ -2511,11 +2511,11 @@ action_challenge_paying (void)
timeout = GNUNET_TIME_UNIT_MINUTES;
GNUNET_assert (NULL == AG_ra);
- args = json_pack ("{s:o, s:s}",
- "timeout",
- GNUNET_JSON_from_time_rel (timeout),
- "payment_secret",
- ps);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_time_rel ("timeout",
+ timeout),
+ GNUNET_JSON_pack_string ("payment_secret",
+ ps));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"pay",
args,
@@ -2915,8 +2915,8 @@ action_recovery_finished (void)
AG_hide_all_frames ();
name = json_string_value (json_object_get (json_object_get (AG_redux_state,
- "recovery_information"),
- "secret_name"));
+ "recovery_information"),
+ "secret_name"));
cs = json_object_get (AG_redux_state,
"core_secret");
@@ -2931,10 +2931,10 @@ action_recovery_finished (void)
if ( (NULL != name) &&
(0 != strlen (name)) )
update_label ("recovery_secret_name_value_label",
- name);
+ name);
else
update_label ("recovery_secret_name_value_label",
- _("You did not name this secret"));
+ _ ("You did not name this secret"));
if ( (0 == strncasecmp (mime,
"text/",
strlen ("text/"))) ||
diff --git a/src/anastasis/anastasis-gtk_attributes.c b/src/anastasis/anastasis-gtk_attributes.c
index bbf3621..238f893 100644
--- a/src/anastasis/anastasis-gtk_attributes.c
+++ b/src/anastasis/anastasis-gtk_attributes.c
@@ -152,9 +152,9 @@ AG_collect_attributes (bool partial)
attr_name,
val));
}
- return json_pack ("{s:o}",
- "identity_attributes",
- result);
+ return GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_object_steal ("identity_attributes",
+ result));
}
diff --git a/src/anastasis/anastasis-gtk_handle-auth-delete-button-clicked.c b/src/anastasis/anastasis-gtk_handle-auth-delete-button-clicked.c
index a431057..d25733e 100644
--- a/src/anastasis/anastasis-gtk_handle-auth-delete-button-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-auth-delete-button-clicked.c
@@ -60,9 +60,9 @@ anastasis_gtk_authentication_method_delete_button_clicked_cb (GObject *object,
AG_AMMC_INDEX, &index,
-1);
AG_freeze ();
- args = json_pack ("{s:I}",
- "authentication_method",
- index);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("authentication_method",
+ index));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"delete_authentication",
args,
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 4bc6558..591a23f 100644
--- a/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
@@ -138,9 +138,9 @@ edit_provider_dialog_response_cb (GtkDialog *dialog,
{
json_t *args;
- args = json_pack ("{s:o}",
- "urls",
- urls);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_array_steal ("urls",
+ urls));
AG_freeze ();
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"add_provider",
diff --git a/src/anastasis/anastasis-gtk_handle-challenge-code.c b/src/anastasis/anastasis-gtk_handle-challenge-code.c
index 046e29e..7a993da 100644
--- a/src/anastasis/anastasis-gtk_handle-challenge-code.c
+++ b/src/anastasis/anastasis-gtk_handle-challenge-code.c
@@ -76,9 +76,9 @@ anastasis_gtk_c_code_dialog_response_cb (GtkDialog *dialog,
GNUNET_break (0);
return;
}
- args = json_pack ("{s:I}",
- "pin",
- (json_int_t) pin);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("pin",
+ pin));
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
AG_freeze ();
diff --git a/src/anastasis/anastasis-gtk_handle-challenge-question.c b/src/anastasis/anastasis-gtk_handle-challenge-question.c
index a947745..d11f469 100644
--- a/src/anastasis/anastasis-gtk_handle-challenge-question.c
+++ b/src/anastasis/anastasis-gtk_handle-challenge-question.c
@@ -63,9 +63,9 @@ anastasis_gtk_c_question_dialog_response_cb (GtkDialog *dialog,
q = GTK_ENTRY (gtk_builder_get_object (builder,
"anastasis_gtk_c_question_dialog_answer_entry"));
qs = gtk_entry_get_text (q);
- args = json_pack ("{s:s}",
- "answer",
- qs);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("answer",
+ qs));
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
AG_freeze ();
diff --git a/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c b/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c
index 0f1023c..4f2c9cb 100644
--- a/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c
+++ b/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c
@@ -48,11 +48,10 @@ start_solve (GtkTreeModel *model,
g_free (uuid);
return;
}
- args = json_pack ("{s:s}",
- "uuid",
- uuid);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("uuid",
+ uuid));
g_free (uuid);
- GNUNET_assert (NULL != args);
AG_freeze ();
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"select_challenge",
diff --git a/src/anastasis/anastasis-gtk_handle-continent-selected.c b/src/anastasis/anastasis-gtk_handle-continent-selected.c
index 8122893..c958799 100644
--- a/src/anastasis/anastasis-gtk_handle-continent-selected.c
+++ b/src/anastasis/anastasis-gtk_handle-continent-selected.c
@@ -61,10 +61,9 @@ anastasis_gtk_continent_selection_changed_cb (GtkTreeSelection *treeselection,
&iter,
AG_CMC_CONTINENT_NAME, &continent_name,
-1);
- arguments = json_pack ("{s:s}",
- "continent",
- continent_name);
- GNUNET_assert (NULL != arguments);
+ arguments = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("continent",
+ continent_name));
g_free (continent_name);
AG_freeze ();
AG_ra = ANASTASIS_redux_action (AG_redux_state,
diff --git a/src/anastasis/anastasis-gtk_handle-core-secret-changed.c b/src/anastasis/anastasis-gtk_handle-core-secret-changed.c
index cc4f787..b086fe5 100644
--- a/src/anastasis/anastasis-gtk_handle-core-secret-changed.c
+++ b/src/anastasis/anastasis-gtk_handle-core-secret-changed.c
@@ -1,6 +1,6 @@
/*
This file is part of anastasis-gtk.
- Copyright (C) 2020 Anastasis SARL
+ Copyright (C) 2020-2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
diff --git a/src/anastasis/anastasis-gtk_handle-core-secret-name-changed.c b/src/anastasis/anastasis-gtk_handle-core-secret-name-changed.c
index 285251f..6be6b6b 100644
--- a/src/anastasis/anastasis-gtk_handle-core-secret-name-changed.c
+++ b/src/anastasis/anastasis-gtk_handle-core-secret-name-changed.c
@@ -42,10 +42,9 @@ anastasis_gtk_enter_secret_name_entry_changed_cb (GtkEditable *entry,
if (AG_in_action)
return;
- arguments = json_pack ("{s:s}",
- "name",
- name);
- GNUNET_assert (NULL != arguments);
+ arguments = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("name",
+ name));
AG_freeze ();
AG_in_secret_name_editing = true;
AG_ra = ANASTASIS_redux_action (AG_redux_state,
diff --git a/src/anastasis/anastasis-gtk_handle-expiration-change.c b/src/anastasis/anastasis-gtk_handle-expiration-change.c
index 99b5412..7c698b7 100644
--- a/src/anastasis/anastasis-gtk_handle-expiration-change.c
+++ b/src/anastasis/anastasis-gtk_handle-expiration-change.c
@@ -94,10 +94,9 @@ expiration_year_spin_button_value_changed_cb (
if (0 == expiration.abs_value_us)
return; /* failured */
(void) GNUNET_TIME_round_abs (&expiration);
- arg = json_pack ("{s:o}",
- "expiration",
- GNUNET_JSON_from_time_abs (expiration));
- GNUNET_assert (NULL != arg);
+ arg = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_time_abs ("expiration",
+ (expiration)));
AG_freeze ();
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"update_expiration",
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
index a85a039..c388361 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
@@ -101,11 +101,13 @@ forward_country_selecting (void)
AG_CCMC_COUNTRY_NAME, &country_name,
AG_CCMC_COUNTRY_CODE, &country_code,
-1);
- arguments = json_pack ("{s:s, s:s, s:o}",
- "country", country_name,
- "country_code", country_code,
- "currencies", currencies);
- GNUNET_assert (NULL != arguments);
+ arguments = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("country",
+ country_name),
+ GNUNET_JSON_pack_string ("country_code",
+ country_code),
+ GNUNET_JSON_pack_array_steal ("currencies",
+ currencies));
g_free (country_name);
g_free (country_code);
AG_freeze ();
diff --git a/src/anastasis/anastasis-gtk_handle-method-post.c b/src/anastasis/anastasis-gtk_handle-method-post.c
index 5269548..5ad954c 100644
--- a/src/anastasis/anastasis-gtk_handle-method-post.c
+++ b/src/anastasis/anastasis-gtk_handle-method-post.c
@@ -86,23 +86,22 @@ anastasis_gtk_b_post_dialog_response_cb (GtkDialog *dialog,
{
json_t *addr;
- addr = json_pack ("{s:s,s:s,s:s,s:s,s:s}",
- "full_name",
- gt (builder,
- "anastasis_gtk_b_post_dialog_full_name_entry"),
- "street",
- gt (builder,
- "anastasis_gtk_b_post_dialog_street_entry"),
- "city",
- gt (builder,
- "anastasis_gtk_b_post_dialog_city_entry"),
- "postcode",
- gt (builder,
- "anastasis_gtk_b_post_dialog_postcode_entry"),
- "country",
- gt (builder,
- "anastasis_gtk_b_post_dialog_country_entry"));
- GNUNET_assert (NULL != addr);
+ addr = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("full_name",
+ gt (builder,
+ "anastasis_gtk_b_post_dialog_full_name_entry")),
+ GNUNET_JSON_pack_string ("street",
+ gt (builder,
+ "anastasis_gtk_b_post_dialog_street_entry")),
+ GNUNET_JSON_pack_string ("city",
+ gt (builder,
+ "anastasis_gtk_b_post_dialog_city_entry")),
+ GNUNET_JSON_pack_string ("postcode",
+ gt (builder,
+ "anastasis_gtk_b_post_dialog_postcode_entry")),
+ GNUNET_JSON_pack_string ("country",
+ gt (builder,
+ "anastasis_gtk_b_post_dialog_country_entry")));
addr_s = json_dumps (addr,
JSON_COMPACT | JSON_SORT_KEYS);
json_decref (addr);
diff --git a/src/anastasis/anastasis-gtk_handle-policy-version-changed.c b/src/anastasis/anastasis-gtk_handle-policy-version-changed.c
index 3f4a14a..63a50c4 100644
--- a/src/anastasis/anastasis-gtk_handle-policy-version-changed.c
+++ b/src/anastasis/anastasis-gtk_handle-policy-version-changed.c
@@ -147,12 +147,11 @@ update_policy (void)
{
json_t *args;
- args = json_pack ("{s:I, s:s}",
- "version",
- (json_int_t) version,
- "provider_url",
- provider_url);
- GNUNET_assert (NULL != args);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("version",
+ version),
+ GNUNET_JSON_pack_string ("provider_url",
+ provider_url));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"change_version",
args,
diff --git a/src/anastasis/anastasis-gtk_pe-delete-challenge.c b/src/anastasis/anastasis-gtk_pe-delete-challenge.c
index d41c983..3f2c39d 100644
--- a/src/anastasis/anastasis-gtk_pe-delete-challenge.c
+++ b/src/anastasis/anastasis-gtk_pe-delete-challenge.c
@@ -36,15 +36,15 @@ AG_delete_challenge (guint pindex,
{
json_t *args;
- args = json_pack ("{s:I, s:I}",
- "policy_index",
- (json_int_t) pindex,
- "challenge_index",
- (json_int_t) mindex);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("policy_index",
+ pindex),
+ GNUNET_JSON_pack_uint64 ("challenge_index",
+ mindex));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
- "delete_challenge",
- args,
- &AG_action_cb,
- NULL);
+ "delete_challenge",
+ args,
+ &AG_action_cb,
+ NULL);
json_decref (args);
}
diff --git a/src/anastasis/anastasis-gtk_pe-delete-policy.c b/src/anastasis/anastasis-gtk_pe-delete-policy.c
index 5fdfb74..3be8fb9 100644
--- a/src/anastasis/anastasis-gtk_pe-delete-policy.c
+++ b/src/anastasis/anastasis-gtk_pe-delete-policy.c
@@ -36,13 +36,13 @@ AG_delete_policy (guint pindex)
{
json_t *args;
- args = json_pack ("{s:I}",
- "policy_index",
- (json_int_t) pindex);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("policy_index",
+ (json_int_t) pindex));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
- "delete_policy",
- args,
- &AG_action_cb,
- NULL);
+ "delete_policy",
+ args,
+ &AG_action_cb,
+ NULL);
json_decref (args);
}
diff --git a/src/anastasis/anastasis-gtk_pe-edit-policy.c b/src/anastasis/anastasis-gtk_pe-edit-policy.c
index f0ac3fb..6803cc2 100644
--- a/src/anastasis/anastasis-gtk_pe-edit-policy.c
+++ b/src/anastasis/anastasis-gtk_pe-edit-policy.c
@@ -50,7 +50,7 @@ struct LineContext
* Kept in a DLL.
*/
struct LineContext *prev;
-
+
/**
* Context this line context belongs with.
*/
@@ -60,17 +60,17 @@ struct LineContext
* Our combo box.
*/
GtkComboBox *cb;
-
+
/**
* Model for our combo box.
*/
GtkTreeModel *model;
-
+
/**
- * Challenge index for this line.
+ * Challenge index for this line.
*/
unsigned int cindex;
-
+
/**
* Is this challenge used?
*/
@@ -107,7 +107,7 @@ struct EditDialogContext
/**
- * Handle the response from the edit dialog.
+ * Handle the response from the edit dialog.
*
* @param dialog the dialog
* @param response_id what the user's action was
@@ -124,65 +124,66 @@ anastasis_gtk_policy_edit_dialog_response_cb (
if (GTK_RESPONSE_OK == response_id)
{
json_t *policy;
-
+
policy = json_array ();
GNUNET_assert (NULL != policy);
for (struct LineContext *lctx = edc->lc_head;
- NULL != lctx;
- lctx = lctx->next)
+ NULL != lctx;
+ lctx = lctx->next)
{
GtkTreeIter iter;
gchar *url;
-
+
if (! lctx->on)
- continue;
+ continue;
if (! gtk_combo_box_get_active_iter (lctx->cb,
- &iter))
+ &iter))
{
- GNUNET_break (0);
- continue;
+ GNUNET_break (0);
+ continue;
}
gtk_tree_model_get (lctx->model,
- &iter,
- 0, &url,
- -1);
- GNUNET_break (0 ==
- json_array_append_new (policy,
- json_pack ("{s:I, s:s}",
- "authentication_method",
- (json_int_t) lctx->cindex,
- "provider",
- url)));
+ &iter,
+ 0, &url,
+ -1);
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ policy,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("authentication_method",
+ lctx->cindex),
+ GNUNET_JSON_pack_string ("provider",
+ url))));
g_free (url);
}
if (UINT_MAX == edc->pindex)
{
json_t *args;
- args = json_pack ("{s:o}",
- "policy",
- (json_int_t) policy);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_array_steal ("policy",
+ policy));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
- "add_policy",
- args,
- &AG_action_cb,
- NULL);
+ "add_policy",
+ args,
+ &AG_action_cb,
+ NULL);
json_decref (args);
}
else
{
json_t *args;
- args = json_pack ("{s:I, s:o}",
- "policy_index",
- (json_int_t) edc->pindex,
- "policy",
- policy);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("policy_index",
+ edc->pindex),
+ GNUNET_JSON_pack_array_steal ("policy",
+ policy));
AG_ra = ANASTASIS_redux_action (AG_redux_state,
- "update_policy",
- args,
- &AG_action_cb,
- NULL);
+ "update_policy",
+ args,
+ &AG_action_cb,
+ NULL);
json_decref (args);
}
}
@@ -190,11 +191,11 @@ anastasis_gtk_policy_edit_dialog_response_cb (
{
struct LineContext *lctx;
- while (NULL != (lctx =edc->lc_head))
+ while (NULL != (lctx = edc->lc_head))
{
GNUNET_CONTAINER_DLL_remove (edc->lc_head,
- edc->lc_tail,
- lctx);
+ edc->lc_tail,
+ lctx);
GNUNET_free (lctx);
}
}
@@ -224,23 +225,23 @@ combo_box_changed_cb (
/* Update our line context's on/off flag */
{
GtkTreeIter iter;
-
+
if (! gtk_combo_box_get_active_iter (lc->cb,
- &iter))
+ &iter))
{
GNUNET_break (0);
}
else
{
gchar *url;
-
+
gtk_tree_model_get (lc->model,
- &iter,
- 0, &url,
- -1);
+ &iter,
+ 0, &url,
+ -1);
lc->on = (0 !=
- strcmp (_("<off>"),
- url));
+ strcmp (_ ("<off>"),
+ url));
g_free (url);
}
}
@@ -250,13 +251,13 @@ combo_box_changed_cb (
bool legal = false;
for (struct LineContext *lctx = edc->lc_head;
- NULL != lctx;
- lctx = lctx->next)
+ NULL != lctx;
+ lctx = lctx->next)
legal |= lctx->on;
ok_button = GTK_WIDGET (gtk_builder_get_object (edc->builder,
- "ok_button"));
+ "ok_button"));
gtk_widget_set_sensitive (ok_button,
- legal);
+ legal);
}
}
@@ -268,31 +269,31 @@ combo_box_changed_cb (
* @param type method to check for
* @param ap provider to check against
* @return true if @a ap offers @a type
- */
+ */
static bool
ap_matches (const char *type,
- json_t *ap)
+ json_t *ap)
{
json_t *methods;
size_t index;
json_t *method;
methods = json_object_get (ap,
- "methods");
+ "methods");
GNUNET_break (NULL != methods);
json_array_foreach (methods, index, method)
{
const char *offer;
offer = json_string_value (json_object_get (method,
- "type"));
+ "type"));
if (NULL == offer)
{
GNUNET_break (0);
continue;
}
if (0 == strcasecmp (type,
- offer))
+ offer))
return true;
}
return false;
@@ -301,7 +302,7 @@ ap_matches (const char *type,
/**
* Create a GtkListStore containing all of the URLs
- * of Anastasis providers offering @a type as an
+ * of Anastasis providers offering @a type as an
* authentication method.
*
* @return the model
@@ -315,26 +316,26 @@ make_model (const char *type)
json_t *ap;
ls = gtk_list_store_new (1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
gtk_list_store_insert_with_values (ls,
- NULL,
- -1,
- 0, _("<off>"),
- -1);
+ NULL,
+ -1,
+ 0, _ ("<off>"),
+ -1);
aps = json_object_get (AG_redux_state,
- "authentication_providers");
+ "authentication_providers");
GNUNET_break (NULL != aps);
json_object_foreach (aps, url, ap) {
if (ap_matches (type,
- ap))
+ ap))
{
gtk_list_store_insert_with_values (ls,
- NULL,
- -1,
- 0, url,
- -1);
+ NULL,
+ -1,
+ 0, url,
+ -1);
}
- }
+ }
return GTK_TREE_MODEL (ls);
}
@@ -348,12 +349,12 @@ make_model (const char *type)
*/
static void
select_by_url (const char *url,
- struct LineContext *lctx)
+ struct LineContext *lctx)
{
GtkTreeIter iter;
if (! gtk_tree_model_get_iter_first (lctx->model,
- &iter))
+ &iter))
{
GNUNET_break (0);
return;
@@ -362,21 +363,21 @@ select_by_url (const char *url,
gchar *have;
gtk_tree_model_get (lctx->model,
- &iter,
- 0, &have,
- -1);
+ &iter,
+ 0, &have,
+ -1);
if (0 == strcmp (have,
- url))
+ url))
{
gtk_combo_box_set_active_iter (lctx->cb,
- &iter);
+ &iter);
lctx->on = true;
g_free (have);
return;
}
g_free (have);
} while (gtk_tree_model_iter_next (lctx->model,
- &iter));
+ &iter));
GNUNET_break (0); /* not found */
}
@@ -390,31 +391,31 @@ select_by_url (const char *url,
*/
static void
select_by_policy (const json_t *methods,
- struct LineContext *lctx)
+ struct LineContext *lctx)
{
size_t index;
json_t *method;
GtkTreeIter iter;
if (! gtk_tree_model_get_iter_first (lctx->model,
- &iter))
+ &iter))
{
GNUNET_break (0);
return;
}
gtk_combo_box_set_active_iter (lctx->cb,
- &iter);
+ &iter);
json_array_foreach (methods, index, method) {
- json_int_t am = json_integer_value (json_object_get (method,\
- "authentication_method"));
+ json_int_t am = json_integer_value (json_object_get (method, \
+ "authentication_method"));
const char *url;
-
+
if (am != lctx->cindex)
continue;
url = json_string_value (json_object_get (method,
- "provider"));
+ "provider"));
select_by_url (url,
- lctx);
+ lctx);
break;
}
}
@@ -426,10 +427,10 @@ AG_edit_policy (guint pindex)
struct EditDialogContext *edc;
GtkGrid *grid;
json_t *methods = NULL;
-
+
edc = GNUNET_new (struct EditDialogContext);
edc->builder = GNUNET_GTK_get_new_builder ("anastasis_gtk_edit_policy.glade",
- edc);
+ edc);
edc->pindex = pindex;
if (NULL == edc->builder)
{
@@ -443,18 +444,18 @@ AG_edit_policy (guint pindex)
json_t *policy;
policies = json_object_get (AG_redux_state,
- "policies");
+ "policies");
policy = json_array_get (policies,
- pindex);
+ pindex);
methods = json_object_get (policy,
- "methods");
+ "methods");
GNUNET_break (NULL != methods);
}
grid = GTK_GRID (gtk_builder_get_object (edc->builder,
- "policy_grid"));
+ "policy_grid"));
{
json_t *ams = json_object_get (AG_redux_state,
- "authentication_methods");
+ "authentication_methods");
json_t *am;
size_t index;
gint row = 1;
@@ -464,10 +465,10 @@ AG_edit_policy (guint pindex)
const char *instructions;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("type",
- &type),
- GNUNET_JSON_spec_string ("instructions",
- &instructions),
- GNUNET_JSON_spec_end ()
+ &type),
+ GNUNET_JSON_spec_string ("instructions",
+ &instructions),
+ GNUNET_JSON_spec_end ()
};
char *labels;
GtkWidget *label;
@@ -475,69 +476,69 @@ AG_edit_policy (guint pindex)
struct LineContext *lctx;
if (GNUNET_OK !=
- GNUNET_JSON_parse (am,
- spec,
- NULL, NULL))
+ GNUNET_JSON_parse (am,
+ spec,
+ NULL, NULL))
{
- GNUNET_break (0);
- continue;
+ GNUNET_break (0);
+ continue;
}
lctx = GNUNET_new (struct LineContext);
lctx->cindex = index;
GNUNET_asprintf (&labels,
- "<b>%s</b>: %s",
- type,
- instructions);
+ "<b>%s</b>: %s",
+ type,
+ instructions);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
- labels);
+ labels);
GNUNET_free (labels);
lctx->model = make_model (type);
cb = gtk_combo_box_new_with_model (lctx->model);
lctx->cb = GTK_COMBO_BOX (cb);
{
- GtkCellRenderer *renderer;
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb),
- renderer,
- true);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cb),
- renderer,
- "text",
- 0);
+ GtkCellRenderer *renderer;
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb),
+ renderer,
+ true);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cb),
+ renderer,
+ "text",
+ 0);
}
lctx->edc = edc;
GNUNET_CONTAINER_DLL_insert (edc->lc_head,
- edc->lc_tail,
- lctx);
+ edc->lc_tail,
+ lctx);
g_object_connect (cb,
- "signal::changed",
- &combo_box_changed_cb, lctx,
- NULL);
+ "signal::changed",
+ &combo_box_changed_cb, lctx,
+ NULL);
if (NULL != methods)
- select_by_policy (methods,
- lctx);
+ select_by_policy (methods,
+ lctx);
gtk_grid_insert_row (grid,
- row);
+ row);
gtk_widget_show (label);
gtk_grid_attach (grid,
- label,
- 0,
- row,
- 1,
- 1);
+ label,
+ 0,
+ row,
+ 1,
+ 1);
g_object_set (cb,
- "expand",
- TRUE,
- NULL);
+ "expand",
+ TRUE,
+ NULL);
gtk_widget_show (cb);
gtk_grid_attach (grid,
- cb,
- 1,
- row,
- 1,
- 1);
+ cb,
+ 1,
+ row,
+ 1,
+ 1);
row++;
}
}
@@ -547,20 +548,22 @@ AG_edit_policy (guint pindex)
GtkWidget *anchor;
GtkRequisition req;
- anchor = GTK_WIDGET (GCG_get_main_window_object ("anastasis_gtk_main_window_quit_button"));
+ anchor = GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_main_window_quit_button"));
toplevel = gtk_widget_get_toplevel (anchor);
ad = GTK_WIDGET (gtk_builder_get_object (edc->builder,
- "anastasis_gtk_policy_edit_dialog"));
+ "anastasis_gtk_policy_edit_dialog"));
gtk_widget_get_preferred_size (ad,
- NULL,
- &req);
+ NULL,
+ &req);
gtk_window_resize (GTK_WINDOW (ad),
- req.width,
- req.height);
+ req.width,
+ req.height);
gtk_window_set_transient_for (GTK_WINDOW (ad),
GTK_WINDOW (toplevel));
gtk_window_present (GTK_WINDOW (ad));
}
}
+
/* end of anastasis-gtk_pe-edit-policy.c */