Keep MUC join dialog open until joined, show errors

This commit is contained in:
fiaxh 2017-10-28 22:02:32 +02:00
parent 7e83529afc
commit d9b91206c0
25 changed files with 365 additions and 230 deletions

View file

@ -43,7 +43,14 @@ public class Message : Object {
/** UTC **/
public DateTime? local_time { get; set; }
public Encryption encryption { get; set; default = Encryption.NONE; }
public Marked marked { get; set; default = Marked.NONE; }
private Marked marked_ = Marked.NONE;
public Marked marked {
get { return marked_; }
set {
if (marked == Marked.RECEIVED && marked == Marked.READ) return;
marked_ = value;
}
}
public Xmpp.Message.Stanza stanza { get; set; }
private Database? db;

View file

@ -9,6 +9,7 @@ public class MucManager : StreamInteractionModule, Object {
public string id { get { return IDENTITY.id; } }
public signal void joined(Account account, Jid jid, string nick);
public signal void enter_error(Account account, Jid jid, Xep.Muc.MucEnterError error);
public signal void left(Account account, Jid jid);
public signal void subject_set(Account account, Jid jid, string? subject);
public signal void bookmarks_updated(Account account, Gee.List<Xep.Bookmarks.Conference> conferences);
@ -29,12 +30,9 @@ public class MucManager : StreamInteractionModule, Object {
}
public void join(Account account, Jid jid, string? nick, string? password) {
if (enter_errors.has_key(jid)) return;
Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream == null) return;
string nick_ = nick ?? account.bare_jid.localpart ?? account.bare_jid.domainpart;
set_autojoin(stream, jid, nick_, password);
DateTime? history_since = null;
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account);
@ -209,11 +207,15 @@ public class MucManager : StreamInteractionModule, Object {
private void on_account_added(Account account) {
stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).room_entered.connect( (stream, jid_string, nick) => {
Jid jid = new Jid(jid_string);
enter_errors.unset(jid);
set_autojoin(stream, jid, nick, null); // TODO password
joined(account, jid, nick);
stream_interactor.get_module(MessageProcessor.IDENTITY).send_unsent_messages(account, jid);
});
stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).room_enter_error.connect( (stream, jid, error) => {
enter_errors[new Jid(jid)] = error;
stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).room_enter_error.connect( (stream, jid_str, error) => {
Jid jid = new Jid(jid_str);
enter_errors[jid] = error;
enter_error(account, jid, error);
});
stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).self_removed_from_room.connect( (stream, jid, code) => {
left(account, new Jid(jid));

View file

@ -72,15 +72,14 @@ SOURCES
src/main.vala
src/ui/application.vala
src/ui/add_conversation/chat/add_contact_dialog.vala
src/ui/add_conversation/chat/roster_list.vala
src/ui/add_conversation/chat/dialog.vala
src/ui/add_conversation/conference/add_groupchat_dialog.vala
src/ui/add_conversation/conference/conference_details_fragment.vala
src/ui/add_conversation/conference/conference_list.vala
src/ui/add_conversation/conference/dialog.vala
src/ui/add_conversation/accounts_combo_box.vala
src/ui/add_conversation/add_conference_dialog.vala
src/ui/add_conversation/add_contact_dialog.vala
src/ui/add_conversation/add_groupchat_dialog.vala
src/ui/add_conversation/conference_details_fragment.vala
src/ui/add_conversation/conference_list.vala
src/ui/add_conversation/list_row.vala
src/ui/add_conversation/roster_list.vala
src/ui/add_conversation/select_contact_dialog.vala
src/ui/add_conversation/select_jid_fragment.vala
src/ui/avatar_generator.vala
src/ui/chat_input/edit_history.vala
@ -121,6 +120,7 @@ SOURCES
src/ui/occupant_menu/view.vala
src/ui/settings_dialog.vala
src/ui/unified_window.vala
src/ui/util/accounts_combo_box.vala
src/ui/util/helper.vala
src/ui/util/label_hybrid.vala
CUSTOM_VAPIS

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="DinoUiAddConversationChatAddContactDialog">
<template class="DinoUiAddContactDialog">
<property name="default_width">300</property>
<property name="modal">True</property>
<child type="titlebar">

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="DinoUiAddConversationConferenceAddGroupchatDialog">
<template class="DinoUiAddGroupchatDialog">
<property name="default_width">400</property>
<property name="modal">True</property>
<child type="titlebar">
@ -170,20 +170,6 @@
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="autojoin_checkbutton">
<property name="active">False</property>
<property name="label" translatable="yes">Join on startup</property>
<property name="xalign">0</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="alias_label">
<property name="label" translatable="yes">Alias</property>
@ -192,7 +178,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -206,7 +192,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>

View file

@ -1,225 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="DinoUiAddConversationConferenceConferenceDetailsFragment">
<template class="DinoUiConferenceDetailsFragment">
<property name="visible">True</property>
<child>
<object class="GtkGrid">
<property name="orientation">vertical</property>
<property name="margin">20</property>
<property name="margin_right">40</property>
<property name="margin_left">40</property>
<property name="row-spacing">7</property>
<property name="column-spacing">10</property>
<object class="GtkOverlay">
<property name="visible">True</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Account</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="accounts_stack">
<object class="GtkGrid">
<property name="orientation">vertical</property>
<property name="margin">20</property>
<property name="margin_right">40</property>
<property name="margin_left">40</property>
<property name="row-spacing">7</property>
<property name="column-spacing">10</property>
<property name="visible">True</property>
<child>
<object class="GtkButton" id="accounts_button">
<property name="relief">none</property>
<object class="GtkLabel">
<property name="label" translatable="yes">Account</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="accounts_stack">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="accounts_label">
<property name="xalign">0</property>
<object class="GtkButton" id="accounts_button">
<property name="relief">none</property>
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="accounts_label">
<property name="xalign">0</property>
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="name">label</property>
</packing>
</child>
<child>
<object class="DinoUiAccountComboBox" id="account_combobox">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visible">True</property>
</object>
<packing>
<property name="name">entry</property>
</packing>
</child>
</object>
<packing>
<property name="name">label</property>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="DinoUiAccountComboBox" id="account_combobox">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<object class="GtkLabel">
<property name="label">JID</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="name">entry</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label">JID</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="jid_stack">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="jid_button">
<property name="relief">none</property>
<object class="GtkStack" id="jid_stack">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="jid_label">
<property name="xalign">0</property>
<object class="GtkButton" id="jid_button">
<property name="relief">none</property>
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="jid_label">
<property name="xalign">0</property>
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="name">label</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="jid_entry">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visible">True</property>
</object>
<packing>
<property name="name">entry</property>
</packing>
</child>
</object>
<packing>
<property name="name">label</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="jid_entry">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<object class="GtkLabel">
<property name="label" translatable="yes">Nick</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="name">entry</property>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Nick</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="nick_stack">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="nick_button">
<property name="relief">none</property>
<object class="GtkStack" id="nick_stack">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="nick_label">
<property name="xalign">0</property>
<object class="GtkButton" id="nick_button">
<property name="relief">none</property>
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="nick_label">
<property name="xalign">0</property>
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="name">label</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="nick_entry">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visible">True</property>
</object>
<packing>
<property name="name">entry</property>
</packing>
</child>
</object>
<packing>
<property name="name">label</property>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="nick_entry">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visible">True</property>
<object class="GtkLabel" id="password_text_label">
<property name="label" translatable="yes">Password</property>
<property name="xalign">1</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="name">entry</property>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Password</property>
<property name="xalign">1</property>
<property name="visible">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="password_stack">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="password_button">
<property name="relief">none</property>
<property name="visible">True</property>
<object class="GtkStack" id="password_stack">
<child>
<object class="GtkLabel" id="password_label">
<property name="xalign">0</property>
<object class="GtkButton" id="password_button">
<property name="relief">none</property>
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="password_label">
<property name="xalign">0</property>
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="name">label</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="password_entry">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visibility">False</property>
<property name="visible">True</property>
</object>
<packing>
<property name="name">entry</property>
</packing>
</child>
</object>
<packing>
<property name="name">label</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="password_entry">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visibility">False</property>
<property name="visible">True</property>
</object>
<packing>
<property name="name">entry</property>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="GtkRevealer" id="notification_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<style>
<class name="app-notification"/>
</style>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">20</property>
<child>
<object class="GtkLabel" id="notification_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This is an app-notification. Click the button to dismiss</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="notification_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close-symbolic</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="DinoUiAddConversationListRow" parent="GtkListBoxRow">
<template class="DinoUiListRow" parent="GtkListBoxRow">
<property name="visible">True</property>
<child>
<object class="GtkGrid" id="outer_grid">

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="DinoUiAddConversationSelectJidFragment">
<template class="DinoUiSelectJidFragment">
<property name="height_request">500</property>
<property name="width_request">460</property>
<property name="visible">True</property>

View file

@ -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() {

View file

@ -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 {

View file

@ -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 {

View file

@ -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;
private StreamInteractor stream_interactor;
[GtkChild] private Revealer notification_revealer;
[GtkChild] private Button notification_button;
[GtkChild] private Label notification_label;
public ConferenceDetailsFragment(StreamInteractor stream_interactor) {
private StreamInteractor stream_interactor;
private Button ok_button;
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");

View file

@ -4,7 +4,7 @@ using Gtk;
using Xmpp;
using Dino.Entities;
namespace Dino.Ui.AddConversation.Conference {
namespace Dino.Ui {
protected class ConferenceList : FilterableList {

View file

@ -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 {

View file

@ -4,7 +4,7 @@ using Gtk;
using Dino.Entities;
using Xmpp;
namespace Dino.Ui.AddConversation.Chat {
namespace Dino.Ui {
protected class RosterList : FilterableList {

View file

@ -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);
});
}
}
}

View file

@ -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 {

View file

@ -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();

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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");

View file

@ -163,7 +163,7 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) {
stream.add_flag(new Muc.Flag());
stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
stream.get_module(Presence.Module.IDENTITY).received_presence.connect(check_for_enter_error);
stream.get_module(Presence.Module.IDENTITY).received_available.connect(on_received_available);
stream.get_module(Presence.Module.IDENTITY).received_unavailable.connect(on_received_unavailable);
if (stream.get_module(ServiceDiscovery.Module.IDENTITY) != null) {
@ -179,7 +179,7 @@ public class Module : XmppStreamModule {
public override void detach(XmppStream stream) {
stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(check_for_enter_error);
stream.get_module(Presence.Module.IDENTITY).received_available.disconnect(on_received_available);
stream.get_module(Presence.Module.IDENTITY).received_unavailable.disconnect(on_received_unavailable);
}
@ -206,7 +206,7 @@ public class Module : XmppStreamModule {
}
}
private void on_received_presence(XmppStream stream, Presence.Stanza presence) {
private void check_for_enter_error(XmppStream stream, Presence.Stanza presence) {
Flag flag = stream.get_flag(Flag.IDENTITY);
if (presence.is_error() && flag.is_muc_enter_outstanding() && flag.is_occupant(presence.from)) {
string bare_jid = get_bare_jid(presence.from);

View file

@ -12,7 +12,9 @@ namespace Xmpp.Xep.Ping {
public void send_ping(XmppStream stream, string jid, owned OnResult? listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("ping", NS_URI).add_self_xmlns());
iq.to = jid;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream) => { listener(stream); });
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream) => {
if (listener != null) listener(stream);
});
}
public override void attach(XmppStream stream) {