wip, fixes https://github.com/dino/dino/issues/261
- server refuses to responds in any way to the sent iq stanza and i don't know why, when i send it with the xml console in gajim it works well
This commit is contained in:
parent
bf9f401743
commit
fc8fdc166b
|
@ -71,6 +71,12 @@ public class Register : StreamInteractionModule, Object{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void change_password(Account account, string new_pw){
|
||||||
|
XmppStream stream = stream_interactor.get_stream(account);
|
||||||
|
if (stream == null) return;
|
||||||
|
yield stream.get_module(Xep.InBandRegistration.Module.IDENTITY).change_password(stream, account.full_jid, new_pw);
|
||||||
|
}
|
||||||
|
|
||||||
public class ServerAvailabilityReturn {
|
public class ServerAvailabilityReturn {
|
||||||
public bool available { get; set; }
|
public bool available { get; set; }
|
||||||
public TlsCertificateFlags? error_flags { get; set; }
|
public TlsCertificateFlags? error_flags { get; set; }
|
||||||
|
|
|
@ -78,6 +78,7 @@ set(RESOURCE_LIST
|
||||||
conversation_content_view/view.ui
|
conversation_content_view/view.ui
|
||||||
manage_accounts/account_row.ui
|
manage_accounts/account_row.ui
|
||||||
manage_accounts/add_account_dialog.ui
|
manage_accounts/add_account_dialog.ui
|
||||||
|
manage_accounts/change_password_dialog.ui
|
||||||
manage_accounts/dialog.ui
|
manage_accounts/dialog.ui
|
||||||
menu_add.ui
|
menu_add.ui
|
||||||
menu_app.ui
|
menu_app.ui
|
||||||
|
@ -217,6 +218,7 @@ SOURCES
|
||||||
|
|
||||||
src/ui/manage_accounts/account_row.vala
|
src/ui/manage_accounts/account_row.vala
|
||||||
src/ui/manage_accounts/add_account_dialog.vala
|
src/ui/manage_accounts/add_account_dialog.vala
|
||||||
|
src/ui/manage_accounts/change_password_dialog.vala
|
||||||
src/ui/manage_accounts/dialog.vala
|
src/ui/manage_accounts/dialog.vala
|
||||||
|
|
||||||
src/ui/occupant_menu/list.vala
|
src/ui/occupant_menu/list.vala
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
<file>manage_accounts/account_row.ui</file>
|
<file>manage_accounts/account_row.ui</file>
|
||||||
<file>manage_accounts/add_account_dialog.ui</file>
|
<file>manage_accounts/add_account_dialog.ui</file>
|
||||||
<file>manage_accounts/dialog.ui</file>
|
<file>manage_accounts/dialog.ui</file>
|
||||||
|
<file>manage_accounts/change_password_dialog.ui</file>
|
||||||
<file>menu_add.ui</file>
|
<file>menu_add.ui</file>
|
||||||
<file>menu_app.ui</file>
|
<file>menu_app.ui</file>
|
||||||
<file>menu_conversation.ui</file>
|
<file>menu_conversation.ui</file>
|
||||||
|
|
113
main/data/manage_accounts/change_password_dialog.ui
Normal file
113
main/data/manage_accounts/change_password_dialog.ui
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="DinoUiChangePasswordDialog">
|
||||||
|
<property name="title" translatable="1">Change password</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="modal">True</property>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar">
|
||||||
|
<property name="show-title-buttons">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="cancel_button">
|
||||||
|
<property name="label" translatable="1">Cancel</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="end">
|
||||||
|
<object class="GtkButton" id="ok_button">
|
||||||
|
<property name="label" translatable="1">Next</property>
|
||||||
|
<property name="sensitive">0</property>
|
||||||
|
<style>
|
||||||
|
<class name="suggested-action"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child internal-child="content_area">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="info_grid">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="margin-start">20</property>
|
||||||
|
<property name="margin-end">20</property>
|
||||||
|
<property name="margin-top">20</property>
|
||||||
|
<property name="margin-bottom">20</property>
|
||||||
|
<property name="row-spacing">7</property>
|
||||||
|
<property name="column-spacing">10</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="1">Current password</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">0</property>
|
||||||
|
<property name="row">0</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="current_passwd_entry">
|
||||||
|
<property name="activates_default">1</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="visibility">False</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">1</property>
|
||||||
|
<property name="row">0</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">New password</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">0</property>
|
||||||
|
<property name="row">1</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="new_passwd_entry">
|
||||||
|
<property name="activates_default">1</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="visibility">False</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">1</property>
|
||||||
|
<property name="row">1</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="1">Confirm new password</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">0</property>
|
||||||
|
<property name="row">2</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="confirm_new_passwd_entry">
|
||||||
|
<property name="activates_default">1</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="visibility">False</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">1</property>
|
||||||
|
<property name="row">2</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<action-widgets>
|
||||||
|
<action-widget response="cancel">cancel_button</action-widget>
|
||||||
|
<action-widget response="ok" default="true">ok_button</action-widget>
|
||||||
|
</action-widgets>
|
||||||
|
</template>
|
||||||
|
</interface>
|
|
@ -165,7 +165,17 @@
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">2</property>
|
<property name="row">2</property>
|
||||||
<property name="column-span">2</property>
|
<property name="column-span">1</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="password_change_btn">
|
||||||
|
<property name="label">⚙️</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">2</property>
|
||||||
|
<property name="row">2</property>
|
||||||
|
<property name="column-span">1</property>
|
||||||
</layout>
|
</layout>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
@ -71,6 +71,7 @@ sources = files(
|
||||||
'src/ui/main_window_controller.vala',
|
'src/ui/main_window_controller.vala',
|
||||||
'src/ui/manage_accounts/account_row.vala',
|
'src/ui/manage_accounts/account_row.vala',
|
||||||
'src/ui/manage_accounts/add_account_dialog.vala',
|
'src/ui/manage_accounts/add_account_dialog.vala',
|
||||||
|
'src/ui/manage_accounts/change_password_dialog.vala',
|
||||||
'src/ui/manage_accounts/dialog.vala',
|
'src/ui/manage_accounts/dialog.vala',
|
||||||
'src/ui/notifier_freedesktop.vala',
|
'src/ui/notifier_freedesktop.vala',
|
||||||
'src/ui/notifier_gnotifications.vala',
|
'src/ui/notifier_gnotifications.vala',
|
||||||
|
|
77
main/src/ui/manage_accounts/change_password_dialog.vala
Normal file
77
main/src/ui/manage_accounts/change_password_dialog.vala
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
using Gee;
|
||||||
|
using Gtk;
|
||||||
|
//using Pango;
|
||||||
|
|
||||||
|
using Dino.Entities;
|
||||||
|
using Xmpp;
|
||||||
|
|
||||||
|
namespace Dino.Ui{
|
||||||
|
|
||||||
|
[GtkTemplate (ui = "/im/dino/Dino/manage_accounts/change_password_dialog.ui")]
|
||||||
|
public class ChangePasswordDialog : Gtk.Dialog {
|
||||||
|
|
||||||
|
[GtkChild] private unowned Button ok_button;
|
||||||
|
[GtkChild] private unowned Button cancel_button;
|
||||||
|
[GtkChild] private unowned Entry current_passwd_entry;
|
||||||
|
[GtkChild] private unowned Entry new_passwd_entry;
|
||||||
|
[GtkChild] private unowned Entry confirm_new_passwd_entry;
|
||||||
|
private bool are_forms_empty;
|
||||||
|
private Account account;
|
||||||
|
private StreamInteractor stream_interactor;
|
||||||
|
|
||||||
|
public ChangePasswordDialog(Account a, StreamInteractor s){
|
||||||
|
Object(use_header_bar : 1);
|
||||||
|
this.stream_interactor = s;
|
||||||
|
this.account = a;
|
||||||
|
cancel_button.clicked.connect(() => { close(); });
|
||||||
|
current_passwd_entry.changed.connect(on_current_passwd_entry_changed);
|
||||||
|
new_passwd_entry.changed.connect(on_new_passwd_entry_changed);
|
||||||
|
confirm_new_passwd_entry.changed.connect(on_confirm_new_passwd_entry_changed);
|
||||||
|
ok_button.clicked.connect(on_ok_button_clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void are_psswd_nonempty(){
|
||||||
|
if (current_passwd_entry.get_text_length() > 0 && new_passwd_entry.get_text_length() > 0 && confirm_new_passwd_entry.get_text_length() > 0){
|
||||||
|
are_forms_empty = false;
|
||||||
|
ok_button.sensitive = true;
|
||||||
|
} else {
|
||||||
|
are_forms_empty = true;
|
||||||
|
ok_button.sensitive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check_new_passwd(){
|
||||||
|
EntryBuffer newpsswd = new_passwd_entry.get_buffer();
|
||||||
|
EntryBuffer confirm_newpsswd = confirm_new_passwd_entry.get_buffer();
|
||||||
|
|
||||||
|
if (newpsswd.get_text() != confirm_newpsswd.get_text()){
|
||||||
|
new_passwd_entry.add_css_class("error");
|
||||||
|
} else {
|
||||||
|
new_passwd_entry.remove_css_class("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_current_passwd_entry_changed(){
|
||||||
|
are_psswd_nonempty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_new_passwd_entry_changed(){
|
||||||
|
are_psswd_nonempty();
|
||||||
|
check_new_passwd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_confirm_new_passwd_entry_changed(){
|
||||||
|
are_psswd_nonempty();
|
||||||
|
check_new_passwd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void on_ok_button_clicked(){
|
||||||
|
string? pw_input = current_passwd_entry.get_buffer().get_text();
|
||||||
|
string? new_pw_input = new_passwd_entry.get_buffer().get_text();
|
||||||
|
if(pw_input != null && account.password == pw_input){
|
||||||
|
stream_interactor.get_module(Register.IDENTITY).change_password.begin(account, new_pw_input);
|
||||||
|
// close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ public class Dialog : Gtk.Dialog {
|
||||||
[GtkChild] public unowned Label state_label;
|
[GtkChild] public unowned Label state_label;
|
||||||
[GtkChild] public unowned Switch active_switch;
|
[GtkChild] public unowned Switch active_switch;
|
||||||
[GtkChild] public unowned Util.EntryLabelHybrid password_hybrid;
|
[GtkChild] public unowned Util.EntryLabelHybrid password_hybrid;
|
||||||
|
[GtkChild] public unowned Button password_change_btn;
|
||||||
[GtkChild] public unowned Util.EntryLabelHybrid alias_hybrid;
|
[GtkChild] public unowned Util.EntryLabelHybrid alias_hybrid;
|
||||||
[GtkChild] public unowned Grid settings_list;
|
[GtkChild] public unowned Grid settings_list;
|
||||||
|
|
||||||
|
@ -44,10 +45,12 @@ public class Dialog : Gtk.Dialog {
|
||||||
image_button.clicked.connect(show_select_avatar);
|
image_button.clicked.connect(show_select_avatar);
|
||||||
alias_hybrid.entry.changed.connect(() => { selected_account.alias = alias_hybrid.text; });
|
alias_hybrid.entry.changed.connect(() => { selected_account.alias = alias_hybrid.text; });
|
||||||
password_hybrid.entry.changed.connect(() => { selected_account.password = password_hybrid.text; });
|
password_hybrid.entry.changed.connect(() => { selected_account.password = password_hybrid.text; });
|
||||||
|
password_change_btn.clicked.connect(show_change_psswd_dialog);
|
||||||
|
|
||||||
Util.LabelHybridGroup label_hybrid_group = new Util.LabelHybridGroup();
|
Util.LabelHybridGroup label_hybrid_group = new Util.LabelHybridGroup();
|
||||||
label_hybrid_group.add(alias_hybrid);
|
label_hybrid_group.add(alias_hybrid);
|
||||||
label_hybrid_group.add(password_hybrid);
|
label_hybrid_group.add(password_hybrid);
|
||||||
|
password_change_btn.sensitive = false;
|
||||||
|
|
||||||
main_stack.set_visible_child_name("no_accounts");
|
main_stack.set_visible_child_name("no_accounts");
|
||||||
|
|
||||||
|
@ -109,6 +112,12 @@ public class Dialog : Gtk.Dialog {
|
||||||
add_account_dialog.present();
|
add_account_dialog.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void show_change_psswd_dialog() {
|
||||||
|
ChangePasswordDialog change_psswd_dialog = new ChangePasswordDialog(selected_account, stream_interactor);
|
||||||
|
change_psswd_dialog.set_transient_for(this);
|
||||||
|
change_psswd_dialog.present();
|
||||||
|
}
|
||||||
|
//
|
||||||
private void remove_account(AccountRow account_item) {
|
private void remove_account(AccountRow account_item) {
|
||||||
Gtk.MessageDialog msg = new Gtk.MessageDialog (
|
Gtk.MessageDialog msg = new Gtk.MessageDialog (
|
||||||
this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
|
this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
|
||||||
|
@ -215,8 +224,10 @@ public class Dialog : Gtk.Dialog {
|
||||||
case ConnectionManager.ConnectionState.CONNECTING:
|
case ConnectionManager.ConnectionState.CONNECTING:
|
||||||
state_label.label = _("Connecting…"); break;
|
state_label.label = _("Connecting…"); break;
|
||||||
case ConnectionManager.ConnectionState.CONNECTED:
|
case ConnectionManager.ConnectionState.CONNECTED:
|
||||||
|
password_change_btn.sensitive = true;
|
||||||
state_label.label = _("Connected"); break;
|
state_label.label = _("Connected"); break;
|
||||||
case ConnectionManager.ConnectionState.DISCONNECTED:
|
case ConnectionManager.ConnectionState.DISCONNECTED:
|
||||||
|
password_change_btn.sensitive = false;
|
||||||
state_label.label = _("Disconnected"); break;
|
state_label.label = _("Disconnected"); break;
|
||||||
}
|
}
|
||||||
state_label.remove_css_class("is_error");
|
state_label.remove_css_class("is_error");
|
||||||
|
@ -224,6 +235,7 @@ public class Dialog : Gtk.Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private string get_connection_error_description(ConnectionManager.ConnectionError error) {
|
private string get_connection_error_description(ConnectionManager.ConnectionError error) {
|
||||||
|
password_change_btn.sensitive = false;
|
||||||
switch (error.source) {
|
switch (error.source) {
|
||||||
case ConnectionManager.ConnectionError.Source.SASL:
|
case ConnectionManager.ConnectionError.Source.SASL:
|
||||||
return _("Wrong password");
|
return _("Wrong password");
|
||||||
|
|
|
@ -29,6 +29,30 @@ public class Module : XmppStreamNegotiationModule {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void change_password(XmppStream stream, Jid jid, string new_pw) {
|
||||||
|
StanzaNode pw_change_node = new StanzaNode.build("query",NS_URI).add_self_xmlns();
|
||||||
|
StanzaNode username_node = new StanzaNode.build("username");
|
||||||
|
StanzaNode pw_node = new StanzaNode.build("password");
|
||||||
|
username_node.put_node(new StanzaNode.text(jid.localpart));
|
||||||
|
pw_node.put_node(new StanzaNode.text(new_pw));
|
||||||
|
pw_change_node.put_node(username_node);
|
||||||
|
pw_change_node.put_node(pw_node);
|
||||||
|
//pw_change_node.put_node(new StanzaNode.build());
|
||||||
|
// StanzaNode execute_chpw = new StanzaNode.build("command","http://jabber.org/protocol/commands").add_self_xmlns();
|
||||||
|
// execute_chpw.put_attribute("node","passwd");
|
||||||
|
// execute_chpw.put_attribute("action","execute");
|
||||||
|
Iq.Stanza set_password_iq = new Iq.Stanza.set(pw_change_node, "changepwtest") { to=jid.bare_jid.domain_jid };
|
||||||
|
|
||||||
|
// Iq.Stanza set_password_iq = new Iq.Stanza.set(execute_chpw) { to=jid.bare_jid.domain_jid };
|
||||||
|
Iq.Stanza chpw_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, set_password_iq);
|
||||||
|
if (chpw_result.is_error()) {
|
||||||
|
ErrorStanza? error_stanza = chpw_result.get_error();
|
||||||
|
stderr.printf("\n" + error_stanza.text ?? "Error when trying to change password \n");
|
||||||
|
}
|
||||||
|
// StanzaNode changepw_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override bool mandatory_outstanding(XmppStream stream) { return false; }
|
public override bool mandatory_outstanding(XmppStream stream) { return false; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue