aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-08-25 21:20:09 +0200
committerfiaxh <git@mx.ax.lt>2017-08-25 22:30:03 +0200
commit8533ba645046e03378d7b9fd3048f15c05f332f7 (patch)
tree8e616e8ac8e598bff9b45dd2237e94361b3635f6 /main
parentf3e587d7663edd6dd2bdb2c87a337156d2e9d0e9 (diff)
downloaddino-8533ba645046e03378d7b9fd3048f15c05f332f7.tar.gz
dino-8533ba645046e03378d7b9fd3048f15c05f332f7.zip
Handle xmpp ?join and ?message uris
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/add_conversation/chat/dialog.vala4
-rw-r--r--main/src/ui/add_conversation/conference/conference_details_fragment.vala1
-rw-r--r--main/src/ui/add_conversation/select_jid_fragment.vala21
-rw-r--r--main/src/ui/application.vala40
-rw-r--r--main/src/ui/chat_input/view.vala5
5 files changed, 54 insertions, 17 deletions
diff --git a/main/src/ui/add_conversation/chat/dialog.vala b/main/src/ui/add_conversation/chat/dialog.vala
index 4b618bc5..361f70ba 100644
--- a/main/src/ui/add_conversation/chat/dialog.vala
+++ b/main/src/ui/add_conversation/chat/dialog.vala
@@ -28,6 +28,10 @@ public class Dialog : Gtk.Dialog {
setup_view();
}
+ public void set_filter(string str) {
+ select_jid_fragment.set_filter(str);
+ }
+
private void setup_headerbar() {
HeaderBar header_bar = get_header_bar() as HeaderBar;
header_bar.show_close_button = false;
diff --git a/main/src/ui/add_conversation/conference/conference_details_fragment.vala b/main/src/ui/add_conversation/conference/conference_details_fragment.vala
index d99681a1..9f9ffe9c 100644
--- a/main/src/ui/add_conversation/conference/conference_details_fragment.vala
+++ b/main/src/ui/add_conversation/conference/conference_details_fragment.vala
@@ -83,6 +83,7 @@ protected class ConferenceDetailsFragment : Box {
password_button.clicked.connect(() => { set_active_stack(password_stack); });
account_combobox.changed.connect(() => { accounts_label.label = account_combobox.selected.bare_jid.to_string(); });
+ accounts_label.label = account_combobox.selected.bare_jid.to_string();
jid_entry.key_release_event.connect(on_jid_key_release_event);
nick_entry.key_release_event.connect(on_nick_key_release_event);
password_entry.key_release_event.connect(on_password_key_release_event);
diff --git a/main/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala
index 98ceb2fa..8e975d2d 100644
--- a/main/src/ui/add_conversation/select_jid_fragment.vala
+++ b/main/src/ui/add_conversation/select_jid_fragment.vala
@@ -11,10 +11,9 @@ public class SelectJidFragment : Gtk.Box {
public signal void add_jid();
public signal void remove_jid(ListRow row);
public bool done {
- get {
- return filterable_list.get_selected_row() != null;
- }
- private set {} }
+ get { return filterable_list.get_selected_row() != null; }
+ private set {}
+ }
[GtkChild] private Entry entry;
[GtkChild] private Box box;
@@ -40,20 +39,18 @@ public class SelectJidFragment : Gtk.Box {
filterable_list.set_sort_func(sort);
filterable_list.row_selected.connect(check_buttons_active);
filterable_list.row_selected.connect(() => { done = true; }); // just for notifying
- entry.changed.connect(on_entry_changed);
+ entry.changed.connect(() => { set_filter(entry.text); });
add_button.clicked.connect(() => { add_jid(); });
remove_button.clicked.connect(() => { remove_jid(filterable_list.get_selected_row() as ListRow); });
}
- private void on_entry_changed() {
- foreach (AddListRow row in added_rows) {
- filterable_list.remove(row);
- }
+ public void set_filter(string str) {
+ if (entry.text != str) entry.text = str;
+
+ foreach (AddListRow row in added_rows) filterable_list.remove(row);
added_rows.clear();
- string[] ? values;
- string str = entry.get_text();
- values = str == "" ? null : str.split(" ");
+ string[] ? values = str == "" ? null : str.split(" ");
filterable_list.set_filter_values(values);
Jid? parsed_jid = Jid.parse(str);
if (parsed_jid != null && parsed_jid.localpart != null) {
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index 6b0db782..0183e30d 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -9,7 +9,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
public Database db { get; set; }
public Dino.Entities.Settings settings { get; set; }
- public StreamInteractor stream_interaction { get; set; }
+ public StreamInteractor stream_interactor { get; set; }
public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); }
public SearchPathGenerator? search_path_generator { get; set; }
@@ -24,8 +24,8 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
activate.connect(() => {
if (window == null) {
create_set_app_menu();
- window = new UnifiedWindow(this, stream_interaction);
- notifications = new Notifications(stream_interaction, window);
+ window = new UnifiedWindow(this, stream_interactor);
+ notifications = new Notifications(stream_interactor, window);
notifications.start();
notifications.conversation_selected.connect(window.on_conversation_selected);
}
@@ -35,14 +35,44 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
public void handle_uri(string jid, string query, Gee.Map<string, string> options) {
switch (query) {
+ 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);
+ ok_button.get_style_context().add_class("suggested-action");
+ AddConversation.Conference.ConferenceDetailsFragment conference_fragment = new AddConversation.Conference.ConferenceDetailsFragment(stream_interactor);
+ conference_fragment.jid = jid;
+ conference_fragment.set_editable();
+ Box content_area = dialog.get_content_area();
+ 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();
+ }
+ });
+ dialog.present();
+ break;
case "message":
- // TODO
+ AddConversation.Chat.Dialog dialog = new AddConversation.Chat.Dialog(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);
+ window.on_conversation_selected(conversation);
+ });
+ dialog.present();
break;
}
}
private void show_accounts_window() {
- ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db);
+ ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interactor, db);
dialog.set_transient_for(window);
dialog.account_enabled.connect(add_connection);
dialog.account_disabled.connect(remove_connection);
diff --git a/main/src/ui/chat_input/view.vala b/main/src/ui/chat_input/view.vala
index 3684e27c..06e59e54 100644
--- a/main/src/ui/chat_input/view.vala
+++ b/main/src/ui/chat_input/view.vala
@@ -13,6 +13,11 @@ public class View : Box {
[GtkChild] private ScrolledWindow scrolled;
[GtkChild] private TextView text_input;
+ public string text {
+ owned get { return text_input.buffer.text; }
+ set { text_input.buffer.text = value; }
+ }
+
private StreamInteractor stream_interactor;
private Conversation? conversation;
private HashMap<Conversation, string> entry_cache = new HashMap<Conversation, string>(Conversation.hash_func, Conversation.equals_func);