aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/manage_accounts
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-08-23 21:19:26 +0200
committerfiaxh <git@lightrise.org>2019-08-23 21:19:26 +0200
commita99c3ff16d3b10209b19a43fc4e810351aeccd61 (patch)
tree91b607070f2a3b4dde9aee80f7ffd2e147929c0c /main/src/ui/manage_accounts
parent130965f322ea58d3d2bbce5ee6ac31dae2d3a659 (diff)
downloaddino-a99c3ff16d3b10209b19a43fc4e810351aeccd61.tar.gz
dino-a99c3ff16d3b10209b19a43fc4e810351aeccd61.zip
Add and enable newly created (first) account
fixes #584
Diffstat (limited to 'main/src/ui/manage_accounts')
-rw-r--r--main/src/ui/manage_accounts/add_account_dialog.vala17
-rw-r--r--main/src/ui/manage_accounts/dialog.vala3
2 files changed, 14 insertions, 6 deletions
diff --git a/main/src/ui/manage_accounts/add_account_dialog.vala b/main/src/ui/manage_accounts/add_account_dialog.vala
index 558738aa..cefc3261 100644
--- a/main/src/ui/manage_accounts/add_account_dialog.vala
+++ b/main/src/ui/manage_accounts/add_account_dialog.vala
@@ -70,12 +70,14 @@ public class AddAccountDialog : Gtk.Dialog {
};
private StreamInteractor stream_interactor;
+ private Database db;
private HashMap<ListBoxRow, string> list_box_jids = new HashMap<ListBoxRow, string>();
private Jid? server_jid = null;
private Xep.InBandRegistration.Form? form = null;
- public AddAccountDialog(StreamInteractor stream_interactor) {
+ public AddAccountDialog(StreamInteractor stream_interactor, Database db) {
this.stream_interactor = stream_interactor;
+ this.db = db;
this.title = _("Add Account");
// Sign in - Jid
@@ -258,8 +260,8 @@ public class AddAccountDialog : Gtk.Dialog {
break;
}
} else {
+ add_activate_account(account);
show_success();
- added(account);
}
}
@@ -343,9 +345,9 @@ public class AddAccountDialog : Gtk.Dialog {
case "password": password = field.get_value_string(); break;
}
}
- Account account = new Account(new Jid(username + "@" + server_jid.domainpart), null, password, null);
+ Account account = new Account(new Jid.components(username, server_jid.domainpart, null), null, password, null);
+ add_activate_account(account);
show_success();
- added(account);
} else {
display_notification(error);
}
@@ -360,6 +362,13 @@ public class AddAccountDialog : Gtk.Dialog {
});
}
+ private void add_activate_account(Account account) {
+ account.enabled = true;
+ account.persist(db);
+ stream_interactor.connect_account(account);
+ added(account);
+ }
+
private void animate_window_resize(Widget widget) { // TODO code duplication
int def_height, curr_width, curr_height;
get_size(out curr_width, out curr_height);
diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala
index bcc0f017..bb0614a2 100644
--- a/main/src/ui/manage_accounts/dialog.vala
+++ b/main/src/ui/manage_accounts/dialog.vala
@@ -108,10 +108,9 @@ public class Dialog : Gtk.Dialog {
}
private void show_add_account_dialog() {
- AddAccountDialog add_account_dialog = new AddAccountDialog(stream_interactor);
+ AddAccountDialog add_account_dialog = new AddAccountDialog(stream_interactor, db);
add_account_dialog.set_transient_for(this);
add_account_dialog.added.connect((account) => {
- account.persist(db);
AccountRow account_item = add_account(account);
account_list.select_row(account_item);
account_list.queue_draw();