aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-11-17 17:53:46 +0100
committerfiaxh <git@lightrise.org>2019-11-17 17:53:46 +0100
commit05561dd677b4098d1a618bcc3e01fc77c5ce19de (patch)
treef25ea04f3e7ef40211c161af366244efc2c206a5 /main/src/ui
parenta2f63a7789aca9e05e5dfd1a9c2838e31aefe60d (diff)
downloaddino-05561dd677b4098d1a618bcc3e01fc77c5ce19de.tar.gz
dino-05561dd677b4098d1a618bcc3e01fc77c5ce19de.zip
Parse presence delivery errors when joining MUC
fixes #224
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/add_conversation/add_conference_dialog.vala8
-rw-r--r--main/src/ui/add_conversation/conference_details_fragment.vala58
-rw-r--r--main/src/ui/application.vala1
3 files changed, 35 insertions, 32 deletions
diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala
index 12a7b57a..9639eed3 100644
--- a/main/src/ui/add_conversation/add_conference_dialog.vala
+++ b/main/src/ui/add_conversation/add_conference_dialog.vala
@@ -3,6 +3,7 @@ using Gtk;
using Dino.Entities;
using Xmpp;
+using Xmpp.Xep;
namespace Dino.Ui {
@@ -49,7 +50,6 @@ public class AddConferenceDialog : Gtk.Dialog {
cancel_button.clicked.connect(on_cancel);
ok_button.label = _("Next");
ok_button.sensitive = select_fragment.done;
- ok_button.clicked.disconnect(on_ok_button_clicked);
ok_button.clicked.connect(on_next_button_clicked);
details_fragment.notify["done"].disconnect(set_ok_sensitive_from_details);
select_fragment.notify["done"].connect(set_ok_sensitive_from_select);
@@ -69,7 +69,6 @@ public class AddConferenceDialog : Gtk.Dialog {
ok_button.label = _("Join");
ok_button.sensitive = details_fragment.done;
ok_button.clicked.disconnect(on_next_button_clicked);
- ok_button.clicked.connect(on_ok_button_clicked);
select_fragment.notify["done"].disconnect(set_ok_sensitive_from_select);
details_fragment.notify["done"].connect(set_ok_sensitive_from_details);
}
@@ -143,7 +142,6 @@ public class AddConferenceDialog : Gtk.Dialog {
Button ok_button = new Button() { label=_("Join"), halign = Align.END, can_focus=true, can_default=true, visible=true };
ok_button.get_style_context().add_class("suggested-action");
- ok_button.clicked.connect(on_ok_button_clicked);
details_fragment.notify["done"].connect(() => { ok_button.sensitive = select_fragment.done; });
details_fragment.ok_button = ok_button;
@@ -182,10 +180,6 @@ public class AddConferenceDialog : Gtk.Dialog {
show_conference_details_view();
}
- private void on_ok_button_clicked() {
- stream_interactor.get_module(MucManager.IDENTITY).join(details_fragment.account, new Jid(details_fragment.jid), details_fragment.nick, details_fragment.password);
- }
-
private void on_joined(Account account, Jid jid, string nick) {
if (account.equals(details_fragment.account) && jid.equals_bare(new Jid(details_fragment.jid))) {
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.GROUPCHAT);
diff --git a/main/src/ui/add_conversation/conference_details_fragment.vala b/main/src/ui/add_conversation/conference_details_fragment.vala
index 5d0ebd9b..876f7050 100644
--- a/main/src/ui/add_conversation/conference_details_fragment.vala
+++ b/main/src/ui/add_conversation/conference_details_fragment.vala
@@ -3,6 +3,7 @@ using Gtk;
using Dino.Entities;
using Xmpp;
+using Xmpp.Xep;
namespace Dino.Ui {
@@ -86,9 +87,9 @@ protected class ConferenceDetailsFragment : Box {
set {
if (value != null) {
value.clicked.connect(() => {
- ok_button.label = _("Joining…");
- ok_button.sensitive = false;
+ on_ok_button_clicked();
});
+
ok_button_ = value;
}
}
@@ -96,7 +97,6 @@ protected class ConferenceDetailsFragment : Box {
public ConferenceDetailsFragment(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
- this.ok_button = ok_button;
account_combobox.initialize(stream_interactor);
@@ -114,7 +114,6 @@ protected class ConferenceDetailsFragment : Box {
jid_entry.key_release_event.connect(() => { done = true; return false; }); // just for notifying
nick_entry.key_release_event.connect(() => { done = true; return false; });
- stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error);
notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); });
clear();
@@ -137,29 +136,40 @@ protected class ConferenceDetailsFragment : Box {
password_stack.set_visible_child_name("entry");
}
- private void on_enter_error(Account account, Jid jid, Xmpp.Xep.Muc.MucEnterError error) {
+ private async void on_ok_button_clicked() {
+ ok_button.label = _("Joining…");
+ ok_button.sensitive = false;
+
+ Muc.JoinResult? join_result = yield stream_interactor.get_module(MucManager.IDENTITY).join(account, new Jid(jid), nick, password);
+
ok_button.label = _("Join");
ok_button.sensitive = true;
+ if (join_result == null || join_result.nick != null) return;
+
string label_text = "";
- switch (error) {
- case Xmpp.Xep.Muc.MucEnterError.PASSWORD_REQUIRED:
- label_text = _("Password required to enter room");
- password_text_label.visible = true;
- password_stack.visible = true;
- break;
- case Xmpp.Xep.Muc.MucEnterError.BANNED:
- label_text = _("Banned from joining or creating conference"); break;
- case Xmpp.Xep.Muc.MucEnterError.ROOM_DOESNT_EXIST:
- label_text = _("Room does not exist"); break;
- case Xmpp.Xep.Muc.MucEnterError.CREATION_RESTRICTED:
- label_text = _("Not allowed to create room"); break;
- case Xmpp.Xep.Muc.MucEnterError.NOT_IN_MEMBER_LIST:
- label_text = _("Members-only room"); break;
- case Xmpp.Xep.Muc.MucEnterError.USE_RESERVED_ROOMNICK:
- case Xmpp.Xep.Muc.MucEnterError.NICK_CONFLICT:
- label_text = _("Choose a different nick"); break;
- case Xmpp.Xep.Muc.MucEnterError.OCCUPANT_LIMIT_REACHED:
- label_text = _("Too many occupants in room"); break;
+ if (join_result.muc_error != null) {
+ switch (join_result.muc_error) {
+ case Muc.MucEnterError.PASSWORD_REQUIRED:
+ label_text = _("Password required to enter room");
+ password_text_label.visible = true;
+ password_stack.visible = true;
+ break;
+ case Muc.MucEnterError.BANNED:
+ label_text = _("Banned from joining or creating conference"); break;
+ case Muc.MucEnterError.ROOM_DOESNT_EXIST:
+ label_text = _("Room does not exist"); break;
+ case Muc.MucEnterError.CREATION_RESTRICTED:
+ label_text = _("Not allowed to create room"); break;
+ case Muc.MucEnterError.NOT_IN_MEMBER_LIST:
+ label_text = _("Members-only room"); break;
+ case Muc.MucEnterError.USE_RESERVED_ROOMNICK:
+ case Muc.MucEnterError.NICK_CONFLICT:
+ label_text = _("Choose a different nick"); break;
+ case Muc.MucEnterError.OCCUPANT_LIMIT_REACHED:
+ label_text = _("Too many occupants in room"); break;
+ }
+ } else if (join_result.stanza_error != null) {
+ label_text = _("Failed connecting to %s").printf((new Jid(jid)).domainpart);
}
notification_label.label = label_text;
notification_revealer.set_reveal_child(true);
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index d9377aeb..138411a0 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -169,7 +169,6 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
content_area.add(conference_fragment);
dialog.response.connect((response_id) => {
if (response_id == ResponseType.OK) {
- stream_interactor.get_module(MucManager.IDENTITY).join(conference_fragment.account, new Jid(conference_fragment.jid), conference_fragment.nick, conference_fragment.password);
dialog.destroy();
} else if (response_id == ResponseType.CANCEL) {
dialog.destroy();