Commit 8a395c17 authored by Evangelos Ribeiro Tzaras's avatar Evangelos Ribeiro Tzaras
Browse files

todo: credential list from acc manager

parent 95bd593c
Pipeline #68564 passed with stages
in 10 minutes and 36 seconds
......@@ -90,7 +90,8 @@ struct _CallsAccountOverview {
/* misc */
CallsAccountOverviewState state;
CallsAccountManager *manager;
CallsCredentials *credentials; // For the editing in the UI
GListModel *credentials; // from the account manager
CallsCredentials *current_credentials; // For the editing in the UI
char *current_uuid; // TODO use this throughout
const char *current_provider;
gboolean user_updated_credentials;
......@@ -308,8 +309,8 @@ edit_credentials (CallsAccountOverview *self,
self->user_updated_credentials = FALSE;
g_clear_object (&self->credentials);
self->credentials = g_object_ref (credentials);
g_clear_object (&self->current_credentials);
self->current_credentials = g_object_ref (credentials);
}
......@@ -338,9 +339,8 @@ on_cancel_clicked (CallsAccountOverview *self)
}
*/
static void
on_login_clicked (CallsAccountOverview *self)
static CallsCredentials *
credentials_from_form (CallsAccountOverview *self)
{
g_autoptr (CallsCredentials) creds = NULL;
GListModel *protocol_model;
......@@ -357,6 +357,7 @@ on_login_clicked (CallsAccountOverview *self)
protocol = g_list_model_get_item (protocol_model, index);
port = atoi (gtk_entry_get_text (GTK_ENTRY (self->port)));
creds = calls_credentials_new ();
g_object_set (G_OBJECT (creds),
......@@ -369,6 +370,20 @@ on_login_clicked (CallsAccountOverview *self)
"provider", self->current_provider,
NULL);
return g_steal_pointer (&creds);
}
static void
on_login_clicked (CallsAccountOverview *self)
{
g_autoptr (CallsCredentials) creds = NULL;
g_assert (CALLS_IS_ACCOUNT_OVERVIEW (self));
creds = credentials_from_form (self);
calls_account_manager_add_credentials (self->manager, creds);
}
......@@ -379,16 +394,20 @@ on_delete_clicked (CallsAccountOverview *self)
g_debug ("Deleting account");
/* TODO once we have a account manager */
calls_account_manager_remove_credentials (self->manager, self->current_uuid);
}
static void
on_apply_clicked (CallsAccountOverview *self)
{
g_autoptr (CallsCredentials) new_creds = NULL;
g_assert (CALLS_IS_ACCOUNT_OVERVIEW (self));
g_debug ("Applying changes to the account");
/* TODO once we have a account manager */
new_creds = credentials_from_form (self);
calls_credentials_update_from_credentials (self->current_credentials, new_creds);
}
......@@ -480,6 +499,8 @@ calls_account_overview_constructed (GObject *object)
G_CALLBACK (on_manager_state_changed),
self);
self->credentials = calls_account_manager_get_credentials_list (self->manager);
on_manager_state_changed (self);
update_visibility (self);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment