aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-28 22:02:32 +0200
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commitd9b91206c0291fa8aa58df572292784a4f8ff878 (patch)
tree09721f9fdffbb87ec8ab25fd1c44a7bc535fffab /main/src
parent7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (diff)
downloaddino-d9b91206c0291fa8aa58df572292784a4f8ff878.tar.gz
dino-d9b91206c0291fa8aa58df572292784a4f8ff878.zip
Keep MUC join dialog open until joined, show errors
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/add_conversation/add_conference_dialog.vala (renamed from main/src/ui/add_conversation/conference/dialog.vala)20
-rw-r--r--main/src/ui/add_conversation/add_contact_dialog.vala (renamed from main/src/ui/add_conversation/chat/add_contact_dialog.vala)2
-rw-r--r--main/src/ui/add_conversation/add_groupchat_dialog.vala (renamed from main/src/ui/add_conversation/conference/add_groupchat_dialog.vala)5
-rw-r--r--main/src/ui/add_conversation/conference_details_fragment.vala (renamed from main/src/ui/add_conversation/conference/conference_details_fragment.vala)55
-rw-r--r--main/src/ui/add_conversation/conference_list.vala (renamed from main/src/ui/add_conversation/conference/conference_list.vala)2
-rw-r--r--main/src/ui/add_conversation/list_row.vala2
-rw-r--r--main/src/ui/add_conversation/roster_list.vala (renamed from main/src/ui/add_conversation/chat/roster_list.vala)2
-rw-r--r--main/src/ui/add_conversation/select_contact_dialog.vala (renamed from main/src/ui/add_conversation/chat/dialog.vala)22
-rw-r--r--main/src/ui/add_conversation/select_jid_fragment.vala2
-rw-r--r--main/src/ui/application.vala12
-rw-r--r--main/src/ui/conversation_list_titlebar.vala10
-rw-r--r--main/src/ui/conversation_selector/list.vala2
-rw-r--r--main/src/ui/notifications.vala2
-rw-r--r--main/src/ui/occupant_menu/view.vala2
-rw-r--r--main/src/ui/util/accounts_combo_box.vala (renamed from main/src/ui/add_conversation/accounts_combo_box.vala)0
15 files changed, 104 insertions, 36 deletions
diff --git a/main/src/ui/add_conversation/conference/dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala
index 10d6e535..5e5698fb 100644
--- a/main/src/ui/add_conversation/conference/dialog.vala
+++ b/main/src/ui/add_conversation/add_conference_dialog.vala
@@ -3,9 +3,9 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation.Conference {
+namespace Dino.Ui {
-public class Dialog : Gtk.Dialog {
+public class AddConferenceDialog : Gtk.Dialog {
public signal void conversation_opened(Conversation conversation);
@@ -21,7 +21,7 @@ public class Dialog : Gtk.Dialog {
private StreamInteractor stream_interactor;
- public Dialog(StreamInteractor stream_interactor) {
+ public AddConferenceDialog(StreamInteractor stream_interactor) {
Object(use_header_bar : 1);
this.title = _("Join Conference");
this.modal = true;
@@ -35,6 +35,8 @@ public class Dialog : Gtk.Dialog {
setup_jid_add_view();
setup_conference_details_view();
show_jid_add_view();
+
+ stream_interactor.get_module(MucManager.IDENTITY).joined.connect((account, jid, nick) => { Idle.add(() => { on_joined(account, jid, nick); return false; } ); });
}
private void show_jid_add_view() {
@@ -102,7 +104,7 @@ public class Dialog : Gtk.Dialog {
}
private void setup_conference_details_view() {
- details_fragment = new ConferenceDetailsFragment(stream_interactor);
+ details_fragment = new ConferenceDetailsFragment(stream_interactor, ok_button);
stack.add_named(details_fragment, "details");
}
@@ -134,7 +136,15 @@ public class Dialog : Gtk.Dialog {
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);
- close();
+ }
+
+ 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);
+ stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
+ conversation_opened(conversation);
+ close();
+ }
}
private void on_cancel() {
diff --git a/main/src/ui/add_conversation/chat/add_contact_dialog.vala b/main/src/ui/add_conversation/add_contact_dialog.vala
index 9c14883a..102cf18a 100644
--- a/main/src/ui/add_conversation/chat/add_contact_dialog.vala
+++ b/main/src/ui/add_conversation/add_contact_dialog.vala
@@ -3,7 +3,7 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation.Chat {
+namespace Dino.Ui {
[GtkTemplate (ui = "/im/dino/add_conversation/add_contact_dialog.ui")]
protected class AddContactDialog : Gtk.Dialog {
diff --git a/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala b/main/src/ui/add_conversation/add_groupchat_dialog.vala
index dc0cfd6d..274ab6f9 100644
--- a/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala
+++ b/main/src/ui/add_conversation/add_groupchat_dialog.vala
@@ -3,7 +3,7 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation.Conference {
+namespace Dino.Ui {
[GtkTemplate (ui = "/im/dino/add_conversation/add_groupchat_dialog.ui")]
protected class AddGroupchatDialog : Gtk.Dialog {
@@ -16,7 +16,6 @@ protected class AddGroupchatDialog : Gtk.Dialog {
[GtkChild] private Entry jid_entry;
[GtkChild] private Entry alias_entry;
[GtkChild] private Entry nick_entry;
- [GtkChild] private CheckButton autojoin_checkbutton;
private StreamInteractor stream_interactor;
private Xmpp.Xep.Bookmarks.Conference? edit_confrence = null;
@@ -46,7 +45,6 @@ protected class AddGroupchatDialog : Gtk.Dialog {
account_combobox.selected = account;
jid_entry.text = conference.jid;
nick_entry.text = conference.nick ?? "";
- autojoin_checkbutton.active = conference.autojoin;
alias_entry.text = conference.name;
}
@@ -69,7 +67,6 @@ protected class AddGroupchatDialog : Gtk.Dialog {
Xmpp.Xep.Bookmarks.Conference conference = new Xmpp.Xep.Bookmarks.Conference(jid_entry.text);
conference.nick = nick_entry.text != "" ? nick_entry.text : null;
conference.name = alias_entry.text;
- conference.autojoin = autojoin_checkbutton.active;
if (edit_confrence == null) {
stream_interactor.get_module(MucManager.IDENTITY).add_bookmark(account_combobox.selected, conference);
} else {
diff --git a/main/src/ui/add_conversation/conference/conference_details_fragment.vala b/main/src/ui/add_conversation/conference_details_fragment.vala
index 9f9ffe9c..064d1053 100644
--- a/main/src/ui/add_conversation/conference/conference_details_fragment.vala
+++ b/main/src/ui/add_conversation/conference_details_fragment.vala
@@ -3,7 +3,7 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation.Conference {
+namespace Dino.Ui {
[GtkTemplate (ui = "/im/dino/add_conversation/conference_details_fragment.ui")]
protected class ConferenceDetailsFragment : Box {
@@ -64,12 +64,20 @@ protected class ConferenceDetailsFragment : Box {
[GtkChild] private Stack password_stack;
[GtkChild] private Button password_button;
[GtkChild] private Label password_label;
+ [GtkChild] private Label password_text_label;
[GtkChild] private Entry password_entry;
+ [GtkChild] private Revealer notification_revealer;
+ [GtkChild] private Button notification_button;
+ [GtkChild] private Label notification_label;
+
private StreamInteractor stream_interactor;
+ private Button ok_button;
- public ConferenceDetailsFragment(StreamInteractor stream_interactor) {
+ public ConferenceDetailsFragment(StreamInteractor stream_interactor, Button ok_button) {
this.stream_interactor = stream_interactor;
+ this.ok_button = ok_button;
+
account_combobox.initialize(stream_interactor);
accounts_stack.set_visible_child_name("label");
@@ -90,6 +98,18 @@ 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((account, jid, error) => {
+ Idle.add(() => {
+ on_enter_error(account, jid, error);
+ return false;
+ });
+ });
+ notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); });
+ ok_button.clicked.connect(() => {
+ ok_button.label = _("Joining...");
+ ok_button.sensitive = false;
+ });
}
public void set_editable() {
@@ -108,9 +128,40 @@ protected class ConferenceDetailsFragment : Box {
jid = "";
nick = "";
password = "";
+ password_text_label.visible = false;
+ password_stack.visible = false;
+ notification_revealer.set_reveal_child(false);
reset_editable();
}
+ private void on_enter_error(Account account, Jid jid, Xmpp.Xep.Muc.MucEnterError error) {
+ ok_button.label = _("Join");
+ ok_button.sensitive = true;
+ 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 = _("Room is members only"); 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 = _("Room has too many occupants"); break;
+ }
+ notification_label.label = label_text;
+ notification_revealer.set_reveal_child(true);
+ }
+
private bool on_jid_key_release_event(EventKey event) {
jid_label.label = jid_entry.text;
if (event.keyval == Key.Return) jid_stack.set_visible_child_name("label");
diff --git a/main/src/ui/add_conversation/conference/conference_list.vala b/main/src/ui/add_conversation/conference_list.vala
index 1f4abfa3..570166b1 100644
--- a/main/src/ui/add_conversation/conference/conference_list.vala
+++ b/main/src/ui/add_conversation/conference_list.vala
@@ -4,7 +4,7 @@ using Gtk;
using Xmpp;
using Dino.Entities;
-namespace Dino.Ui.AddConversation.Conference {
+namespace Dino.Ui {
protected class ConferenceList : FilterableList {
diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala
index 5c33095f..fa607841 100644
--- a/main/src/ui/add_conversation/list_row.vala
+++ b/main/src/ui/add_conversation/list_row.vala
@@ -3,7 +3,7 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation {
+namespace Dino.Ui {
[GtkTemplate (ui = "/im/dino/add_conversation/list_row.ui")]
public class ListRow : ListBoxRow {
diff --git a/main/src/ui/add_conversation/chat/roster_list.vala b/main/src/ui/add_conversation/roster_list.vala
index f4b42cc4..70e4bc14 100644
--- a/main/src/ui/add_conversation/chat/roster_list.vala
+++ b/main/src/ui/add_conversation/roster_list.vala
@@ -4,7 +4,7 @@ using Gtk;
using Dino.Entities;
using Xmpp;
-namespace Dino.Ui.AddConversation.Chat {
+namespace Dino.Ui {
protected class RosterList : FilterableList {
diff --git a/main/src/ui/add_conversation/chat/dialog.vala b/main/src/ui/add_conversation/select_contact_dialog.vala
index 361f70ba..b05762ec 100644
--- a/main/src/ui/add_conversation/chat/dialog.vala
+++ b/main/src/ui/add_conversation/select_contact_dialog.vala
@@ -4,9 +4,9 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation.Chat {
+namespace Dino.Ui {
-public class Dialog : Gtk.Dialog {
+public class SelectContactDialog : Gtk.Dialog {
public signal void selected(Account account, Jid jid);
@@ -17,7 +17,7 @@ public class Dialog : Gtk.Dialog {
private StreamInteractor stream_interactor;
private Gee.List<Account> accounts;
- public Dialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
+ public SelectContactDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
Object(use_header_bar : 1);
modal = true;
@@ -75,4 +75,20 @@ public class Dialog : Gtk.Dialog {
}
}
+public class AddChatDialog : SelectContactDialog {
+
+ public signal void added(Conversation conversation);
+
+ public AddChatDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
+ base(stream_interactor, accounts);
+ title = _("Start Chat");
+ ok_button.label = _("Start");
+ selected.connect((account, jid) => {
+ Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
+ stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
+ added(conversation);
+ });
+ }
+}
+
}
diff --git a/main/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala
index 8e975d2d..d34a22d7 100644
--- a/main/src/ui/add_conversation/select_jid_fragment.vala
+++ b/main/src/ui/add_conversation/select_jid_fragment.vala
@@ -3,7 +3,7 @@ using Gtk;
using Dino.Entities;
-namespace Dino.Ui.AddConversation {
+namespace Dino.Ui {
[GtkTemplate (ui = "/im/dino/add_conversation/select_jid_fragment.ui")]
public class SelectJidFragment : Gtk.Box {
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index ff5f44ac..625673fb 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -40,9 +40,9 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
case "join":
Dialog dialog = new Dialog.with_buttons(_("Join Conference"), window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.USE_HEADER_BAR, _("Join"), ResponseType.OK, _("Cancel"), ResponseType.CANCEL);
dialog.modal = true;
- Widget ok_button = dialog.get_widget_for_response(ResponseType.OK);
+ Button ok_button = dialog.get_widget_for_response(ResponseType.OK) as Button;
ok_button.get_style_context().add_class("suggested-action");
- AddConversation.Conference.ConferenceDetailsFragment conference_fragment = new AddConversation.Conference.ConferenceDetailsFragment(stream_interactor);
+ ConferenceDetailsFragment conference_fragment = new ConferenceDetailsFragment(stream_interactor, ok_button);
conference_fragment.jid = jid;
conference_fragment.set_editable();
Box content_area = dialog.get_content_area();
@@ -64,14 +64,10 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
window.on_conversation_selected(conversation);
} else {
- AddConversation.Chat.Dialog dialog = new AddConversation.Chat.Dialog(stream_interactor, stream_interactor.get_accounts());
+ AddChatDialog dialog = new AddChatDialog(stream_interactor, stream_interactor.get_accounts());
dialog.set_filter(jid);
dialog.set_transient_for(window);
- dialog.title = _("Start Chat");
- dialog.ok_button.label = _("Start");
- dialog.selected.connect((account, jid) => {
- Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
- stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
+ dialog.added.connect((conversation) => {
window.on_conversation_selected(conversation);
});
dialog.present();
diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala
index 815807f2..e499c6d5 100644
--- a/main/src/ui/conversation_list_titlebar.vala
+++ b/main/src/ui/conversation_list_titlebar.vala
@@ -26,13 +26,9 @@ public class ConversationListTitlebar : Gtk.HeaderBar {
private void create_add_menu(Window window) {
SimpleAction contacts_action = new SimpleAction("add_chat", null);
contacts_action.activate.connect(() => {
- AddConversation.Chat.Dialog add_chat_dialog = new AddConversation.Chat.Dialog(stream_interactor, stream_interactor.get_accounts());
+ AddChatDialog add_chat_dialog = new AddChatDialog(stream_interactor, stream_interactor.get_accounts());
add_chat_dialog.set_transient_for(window);
- add_chat_dialog.title = _("Start Chat");
- add_chat_dialog.ok_button.label = _("Start");
- add_chat_dialog.selected.connect((account, jid) => {
- Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
- stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
+ add_chat_dialog.added.connect((conversation) => {
conversation_opened(conversation);
});
add_chat_dialog.present();
@@ -41,7 +37,7 @@ public class ConversationListTitlebar : Gtk.HeaderBar {
SimpleAction conference_action = new SimpleAction("add_conference", null);
conference_action.activate.connect(() => {
- AddConversation.Conference.Dialog add_conference_dialog = new AddConversation.Conference.Dialog(stream_interactor);
+ AddConferenceDialog add_conference_dialog = new AddConferenceDialog(stream_interactor);
add_conference_dialog.set_transient_for(window);
add_conference_dialog.conversation_opened.connect((conversation) => conversation_opened(conversation));
add_conference_dialog.present();
diff --git a/main/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala
index 6e9a0ec2..dbad72a8 100644
--- a/main/src/ui/conversation_selector/list.vala
+++ b/main/src/ui/conversation_selector/list.vala
@@ -144,6 +144,8 @@ public class List : ListBox {
private void header(ListBoxRow row, ListBoxRow? before_row) {
if (row.get_header() == null && before_row != null) {
row.set_header(new Separator(Orientation.HORIZONTAL));
+ } else if (row.get_header() != null && before_row == null) {
+ row.set_header(null);
}
}
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala
index b3a373be..cfbec8dc 100644
--- a/main/src/ui/notifications.vala
+++ b/main/src/ui/notifications.vala
@@ -54,7 +54,7 @@ public class Notifications : Object {
if (conversation == null) return;
stream_interactor.get_module(PresenceManager.IDENTITY).approve_subscription(conversation.account, conversation.counterpart);
if (stream_interactor.get_module(RosterManager.IDENTITY).get_roster_item(conversation.account, conversation.counterpart) == null) {
- AddConversation.Chat.AddContactDialog dialog = new AddConversation.Chat.AddContactDialog(stream_interactor);
+ AddContactDialog dialog = new AddContactDialog(stream_interactor);
dialog.jid = conversation.counterpart.bare_jid.to_string();
dialog.account = conversation.account;
dialog.present();
diff --git a/main/src/ui/occupant_menu/view.vala b/main/src/ui/occupant_menu/view.vala
index b93e38e6..fb63a06a 100644
--- a/main/src/ui/occupant_menu/view.vala
+++ b/main/src/ui/occupant_menu/view.vala
@@ -29,7 +29,7 @@ public class View : Popover {
hide();
Gee.List<Account> acc_list = new ArrayList<Account>(Account.equals_func);
acc_list.add(conversation.account);
- AddConversation.Chat.Dialog add_chat_dialog = new AddConversation.Chat.Dialog(stream_interactor, acc_list);
+ SelectContactDialog add_chat_dialog = new SelectContactDialog(stream_interactor, acc_list);
add_chat_dialog.set_transient_for(window);
add_chat_dialog.title = _("Invite to Conference");
add_chat_dialog.ok_button.label = _("Invite");
diff --git a/main/src/ui/add_conversation/accounts_combo_box.vala b/main/src/ui/util/accounts_combo_box.vala
index 5fdd18e6..5fdd18e6 100644
--- a/main/src/ui/add_conversation/accounts_combo_box.vala
+++ b/main/src/ui/util/accounts_combo_box.vala