aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/add_conversation')
-rw-r--r--main/src/ui/add_conversation/accounts_combo_box.vala57
-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
10 files changed, 93 insertions, 76 deletions
diff --git a/main/src/ui/add_conversation/accounts_combo_box.vala b/main/src/ui/add_conversation/accounts_combo_box.vala
deleted file mode 100644
index 5fdd18e6..00000000
--- a/main/src/ui/add_conversation/accounts_combo_box.vala
+++ /dev/null
@@ -1,57 +0,0 @@
-using Gee;
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Ui {
-
-class AccountComboBox : ComboBox {
-
- public Account? selected {
- get {
- TreeIter selected;
- if (get_active_iter(out selected)) {
- Value value;
- list_store.get_value(selected, 1, out value);
- return value as Account;
- }
- return null;
- }
- set {
- TreeIter iter;
- if (list_store.get_iter_first(out iter)) {
- int i = 0;
- do {
- Value val;
- list_store.get_value(iter, 1, out val);
- if ((val as Account).equals(value)) {
- active = i;
- break;
- }
- i++;
- } while (list_store.iter_next(ref iter));
- }
- }
- }
-
- private StreamInteractor? stream_interactor;
- private Gtk.ListStore list_store = new Gtk.ListStore(2, typeof(string), typeof(Account));
-
- public void initialize(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
-
- CellRendererText renderer = new Gtk.CellRendererText();
- pack_start(renderer, true);
- add_attribute(renderer, "text", 0);
-
- TreeIter iter;
- foreach (Account account in stream_interactor.get_accounts()) {
- list_store.append(out iter);
- list_store.set(iter, 0, account.bare_jid.to_string(), 1, account);
- }
- set_model(list_store);
- active = 0;
- }
-}
-
-}
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 {