Handle xmpp ?join and ?message uris
This commit is contained in:
parent
f3e587d766
commit
8533ba6450
|
@ -4,7 +4,7 @@ public interface Dino.Application : GLib.Application {
|
|||
|
||||
public abstract Database db { get; set; }
|
||||
public abstract Dino.Entities.Settings settings { get; set; }
|
||||
public abstract StreamInteractor stream_interaction { get; set; }
|
||||
public abstract StreamInteractor stream_interactor { get; set; }
|
||||
public abstract Plugins.Registry plugin_registry { get; set; }
|
||||
public abstract SearchPathGenerator? search_path_generator { get; set; }
|
||||
|
||||
|
@ -24,20 +24,20 @@ public interface Dino.Application : GLib.Application {
|
|||
|
||||
this.db = new Database(Path.build_filename(get_storage_dir(), "dino.db"));
|
||||
this.settings = new Dino.Entities.Settings.from_db(db);
|
||||
this.stream_interaction = new StreamInteractor(db);
|
||||
this.stream_interactor = new StreamInteractor(db);
|
||||
|
||||
AvatarManager.start(stream_interaction, db);
|
||||
MessageProcessor.start(stream_interaction, db);
|
||||
MessageStorage.start(stream_interaction, db);
|
||||
CounterpartInteractionManager.start(stream_interaction);
|
||||
PresenceManager.start(stream_interaction);
|
||||
MucManager.start(stream_interaction);
|
||||
RosterManager.start(stream_interaction, db);
|
||||
ConversationManager.start(stream_interaction, db);
|
||||
ChatInteraction.start(stream_interaction);
|
||||
AvatarManager.start(stream_interactor, db);
|
||||
MessageProcessor.start(stream_interactor, db);
|
||||
MessageStorage.start(stream_interactor, db);
|
||||
CounterpartInteractionManager.start(stream_interactor);
|
||||
PresenceManager.start(stream_interactor);
|
||||
MucManager.start(stream_interactor);
|
||||
RosterManager.start(stream_interactor, db);
|
||||
ConversationManager.start(stream_interactor, db);
|
||||
ChatInteraction.start(stream_interactor);
|
||||
|
||||
activate.connect(() => {
|
||||
stream_interaction.connection_manager.log_options = print_xmpp;
|
||||
stream_interactor.connection_manager.log_options = print_xmpp;
|
||||
restore();
|
||||
});
|
||||
open.connect((files, hint) => {
|
||||
|
@ -86,11 +86,11 @@ public interface Dino.Application : GLib.Application {
|
|||
}
|
||||
|
||||
protected void add_connection(Account account) {
|
||||
stream_interaction.connect(account);
|
||||
stream_interactor.connect(account);
|
||||
}
|
||||
|
||||
protected void remove_connection(Account account) {
|
||||
stream_interaction.disconnect(account);
|
||||
stream_interactor.disconnect(account);
|
||||
}
|
||||
|
||||
private void restore() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -11,13 +11,13 @@ public class Plugin : RootInterface, Object {
|
|||
public void registered(Dino.Application app) {
|
||||
try {
|
||||
this.app = app;
|
||||
this.conversations_titlebar_entry = new ConversationsTitlebarEntry(app.stream_interaction);
|
||||
this.conversations_titlebar_entry = new ConversationsTitlebarEntry(app.stream_interactor);
|
||||
|
||||
this.app.plugin_registry.register_contact_titlebar_entry(conversations_titlebar_entry);
|
||||
this.app.stream_interaction.module_manager.initialize_account_modules.connect((account, list) => {
|
||||
this.app.stream_interactor.module_manager.initialize_account_modules.connect((account, list) => {
|
||||
list.add(new UploadStreamModule());
|
||||
});
|
||||
Manager.start(this.app.stream_interaction);
|
||||
Manager.start(this.app.stream_interactor);
|
||||
} catch (Error e) {
|
||||
print(@"Error initializing http-files: $(e.message)\n");
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
|
|||
}}
|
||||
|
||||
public bool can_encrypt(Entities.Conversation conversation) {
|
||||
return plugin.app.stream_interaction.get_module(Manager.IDENTITY).can_encrypt(conversation);
|
||||
return plugin.app.stream_interactor.get_module(Manager.IDENTITY).can_encrypt(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ public class Plugin : RootInterface, Object {
|
|||
this.settings_entry = new AccountSettingsEntry(this);
|
||||
this.app.plugin_registry.register_encryption_list_entry(list_entry);
|
||||
this.app.plugin_registry.register_account_settings_entry(settings_entry);
|
||||
this.app.stream_interaction.module_manager.initialize_account_modules.connect((account, list) => {
|
||||
this.app.stream_interactor.module_manager.initialize_account_modules.connect((account, list) => {
|
||||
list.add(new StreamModule());
|
||||
});
|
||||
Manager.start(this.app.stream_interaction, db);
|
||||
Manager.start(this.app.stream_interactor, db);
|
||||
|
||||
string locales_dir;
|
||||
if (app.search_path_generator != null) {
|
||||
|
@ -59,4 +59,4 @@ public class Plugin : RootInterface, Object {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,16 +19,16 @@ public class Plugin : Plugins.RootInterface, Object {
|
|||
public void registered(Dino.Application app) {
|
||||
this.app = app;
|
||||
this.db = new Database(Path.build_filename(Application.get_storage_dir(), "pgp.db"));
|
||||
this.list_entry = new EncryptionListEntry(app.stream_interaction);
|
||||
this.list_entry = new EncryptionListEntry(app.stream_interactor);
|
||||
this.settings_entry = new AccountSettingsEntry(this);
|
||||
this.contact_details_provider = new ContactDetailsProvider(app.stream_interaction);
|
||||
this.contact_details_provider = new ContactDetailsProvider(app.stream_interactor);
|
||||
|
||||
app.plugin_registry.register_encryption_list_entry(list_entry);
|
||||
app.plugin_registry.register_account_settings_entry(settings_entry);
|
||||
app.plugin_registry.register_contact_details_entry(contact_details_provider);
|
||||
app.stream_interaction.module_manager.initialize_account_modules.connect(on_initialize_account_modules);
|
||||
app.stream_interactor.module_manager.initialize_account_modules.connect(on_initialize_account_modules);
|
||||
|
||||
Manager.start(app.stream_interaction, db);
|
||||
Manager.start(app.stream_interactor, db);
|
||||
|
||||
internationalize(GETTEXT_PACKAGE, app.search_path_generator.get_locale_path(GETTEXT_PACKAGE, LOCALE_INSTALL_DIR));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue