Split login jid/password into two steps with checks
This commit is contained in:
parent
45236d07bc
commit
fa731a4623
|
@ -40,6 +40,7 @@ public interface Dino.Application : GLib.Application {
|
||||||
ContentItemStore.start(stream_interactor, db);
|
ContentItemStore.start(stream_interactor, db);
|
||||||
NotificationEvents.start(stream_interactor);
|
NotificationEvents.start(stream_interactor);
|
||||||
SearchProcessor.start(stream_interactor, db);
|
SearchProcessor.start(stream_interactor, db);
|
||||||
|
Register.start(stream_interactor, db);
|
||||||
|
|
||||||
create_actions();
|
create_actions();
|
||||||
|
|
||||||
|
@ -110,11 +111,11 @@ public interface Dino.Application : GLib.Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void add_connection(Account account) {
|
protected void add_connection(Account account) {
|
||||||
stream_interactor.connect(account);
|
stream_interactor.connect_account(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void remove_connection(Account account) {
|
protected void remove_connection(Account account) {
|
||||||
stream_interactor.disconnect(account);
|
stream_interactor.disconnect_account(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restore() {
|
private void restore() {
|
||||||
|
|
|
@ -44,6 +44,8 @@ public class Account : Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void persist(Database db) {
|
public void persist(Database db) {
|
||||||
|
if (id > 0) return;
|
||||||
|
|
||||||
this.db = db;
|
this.db = db;
|
||||||
id = (int) db.account.insert()
|
id = (int) db.account.insert()
|
||||||
.value(db.account.bare_jid, bare_jid.to_string())
|
.value(db.account.bare_jid, bare_jid.to_string())
|
||||||
|
|
|
@ -5,7 +5,7 @@ using Dino.Entities;
|
||||||
|
|
||||||
namespace Dino {
|
namespace Dino {
|
||||||
|
|
||||||
public class ConnectionManager {
|
public class ConnectionManager : Object {
|
||||||
|
|
||||||
public signal void stream_opened(Account account, XmppStream stream);
|
public signal void stream_opened(Account account, XmppStream stream);
|
||||||
public signal void connection_state_changed(Account account, ConnectionState state);
|
public signal void connection_state_changed(Account account, ConnectionState state);
|
||||||
|
@ -133,7 +133,7 @@ public class ConnectionManager {
|
||||||
connections[account].stream.get_module(Presence.Module.IDENTITY).send_presence(connections[account].stream, presence);
|
connections[account].stream.get_module(Presence.Module.IDENTITY).send_presence(connections[account].stream, presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(Account account) {
|
public void disconnect_account(Account account) {
|
||||||
if (connections.has_key(account)) {
|
if (connections.has_key(account)) {
|
||||||
make_offline(account);
|
make_offline(account);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,12 +5,96 @@ using Dino.Entities;
|
||||||
|
|
||||||
namespace Dino {
|
namespace Dino {
|
||||||
|
|
||||||
public class Register {
|
public class Register : StreamInteractionModule, Object{
|
||||||
|
public static ModuleIdentity<Register> IDENTITY = new ModuleIdentity<Register>("registration");
|
||||||
|
public string id { get { return IDENTITY.id; } }
|
||||||
|
|
||||||
|
private StreamInteractor stream_interactor;
|
||||||
|
private Database db;
|
||||||
|
|
||||||
|
public static void start(StreamInteractor stream_interactor, Database db) {
|
||||||
|
Register m = new Register(stream_interactor, db);
|
||||||
|
stream_interactor.add_module(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Register(StreamInteractor stream_interactor, Database db) {
|
||||||
|
this.stream_interactor = stream_interactor;
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ConnectionManager.ConnectionError.Source? add_check_account(Account account) {
|
||||||
|
SourceFunc callback = add_check_account.callback;
|
||||||
|
ConnectionManager.ConnectionError.Source? ret = null;
|
||||||
|
|
||||||
|
ulong handler_id_connected = stream_interactor.stream_negotiated.connect((connected_account, stream) => {
|
||||||
|
if (connected_account.equals(account)) {
|
||||||
|
account.persist(db);
|
||||||
|
account.enabled = true;
|
||||||
|
Idle.add((owned)callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ulong handler_id_error = stream_interactor.connection_manager.connection_error.connect((connected_account, error) => {
|
||||||
|
if (connected_account.equals(account)) {
|
||||||
|
ret = error.source;
|
||||||
|
}
|
||||||
|
stream_interactor.disconnect_account(account);
|
||||||
|
Idle.add((owned)callback);
|
||||||
|
});
|
||||||
|
|
||||||
|
stream_interactor.connect_account(account);
|
||||||
|
yield;
|
||||||
|
stream_interactor.disconnect(handler_id_connected);
|
||||||
|
stream_interactor.connection_manager.disconnect(handler_id_error);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ServerAvailabilityReturn {
|
||||||
|
public bool available { get; set; }
|
||||||
|
public TlsCertificateFlags? error_flags { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async ServerAvailabilityReturn check_server_availability(Jid jid) {
|
||||||
|
XmppStream stream = new XmppStream();
|
||||||
|
stream.add_module(new Tls.Module());
|
||||||
|
stream.add_module(new Iq.Module());
|
||||||
|
stream.add_module(new Xep.SrvRecordsTls.Module());
|
||||||
|
|
||||||
|
ServerAvailabilityReturn ret = new ServerAvailabilityReturn() { available=false };
|
||||||
|
SourceFunc callback = check_server_availability.callback;
|
||||||
|
stream.stream_negotiated.connect(() => {
|
||||||
|
if (callback != null) {
|
||||||
|
ret.available = true;
|
||||||
|
Idle.add((owned)callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
stream.get_module(Tls.Module.IDENTITY).invalid_certificate.connect((peer_cert, errors) => {
|
||||||
|
if (callback != null) {
|
||||||
|
|
||||||
|
ret.error_flags = errors;
|
||||||
|
Idle.add((owned)callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Timeout.add_seconds(5, () => {
|
||||||
|
if (callback != null) {
|
||||||
|
Idle.add((owned)callback);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.connect.begin(jid.domainpart);
|
||||||
|
yield;
|
||||||
|
try {
|
||||||
|
stream.disconnect();
|
||||||
|
} catch (Error e) {}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public static async Xep.InBandRegistration.Form get_registration_form(Jid jid) {
|
public static async Xep.InBandRegistration.Form get_registration_form(Jid jid) {
|
||||||
XmppStream stream = new XmppStream();
|
XmppStream stream = new XmppStream();
|
||||||
stream.add_module(new Tls.Module());
|
stream.add_module(new Tls.Module());
|
||||||
stream.add_module(new Iq.Module());
|
stream.add_module(new Iq.Module());
|
||||||
|
stream.add_module(new Xep.SrvRecordsTls.Module());
|
||||||
stream.add_module(new Xep.InBandRegistration.Module());
|
stream.add_module(new Xep.InBandRegistration.Module());
|
||||||
stream.connect.begin(jid.bare_jid.to_string());
|
stream.connect.begin(jid.bare_jid.to_string());
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ using Dino.Entities;
|
||||||
|
|
||||||
namespace Dino {
|
namespace Dino {
|
||||||
|
|
||||||
public class StreamInteractor {
|
public class StreamInteractor : Object {
|
||||||
|
|
||||||
public signal void account_added(Account account);
|
public signal void account_added(Account account);
|
||||||
public signal void account_removed(Account account);
|
public signal void account_removed(Account account);
|
||||||
|
@ -23,14 +23,14 @@ public class StreamInteractor {
|
||||||
connection_manager.stream_opened.connect(on_stream_opened);
|
connection_manager.stream_opened.connect(on_stream_opened);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(Account account) {
|
public void connect_account(Account account) {
|
||||||
module_manager.initialize(account);
|
module_manager.initialize(account);
|
||||||
account_added(account);
|
account_added(account);
|
||||||
connection_manager.connect(account);
|
connection_manager.connect(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(Account account) {
|
public void disconnect_account(Account account) {
|
||||||
connection_manager.disconnect(account);
|
connection_manager.disconnect_account(account);
|
||||||
account_removed(account);
|
account_removed(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ set(RESOURCE_LIST
|
||||||
icons/dino-changes-prevent-symbolic.svg
|
icons/dino-changes-prevent-symbolic.svg
|
||||||
icons/dino-double-tick-symbolic.svg
|
icons/dino-double-tick-symbolic.svg
|
||||||
icons/dino-qr-code-symbolic.svg
|
icons/dino-qr-code-symbolic.svg
|
||||||
|
icons/dino-party-popper-symbolic.svg
|
||||||
icons/dino-status-away.svg
|
icons/dino-status-away.svg
|
||||||
icons/dino-status-chat.svg
|
icons/dino-status-chat.svg
|
||||||
icons/dino-status-dnd.svg
|
icons/dino-status-dnd.svg
|
||||||
|
|
29
main/data/icons/dino-party-popper-symbolic.svg
Normal file
29
main/data/icons/dino-party-popper-symbolic.svg
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg version="1.1" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<path d="m34.139 52.305c-2.3304-0.11119-4.1522 0.452-5.3574 1.6562-0.40199 0.38434-0.9571 1.1617-1.2525 2.0357l-22.228 61.974c-1.29 3.58 2.1698 7.0398 5.7598 5.7598l59.266-21.23c2.3204 0.10655 4.1346-0.45724 5.3359-1.6582 4.9723-4.9769-1.4894-19.503-14.434-32.447-9.4181-9.4182-20.088-15.756-27.09-16.09z" style="fill-rule:evenodd;opacity:.9"/>
|
||||||
|
<defs>
|
||||||
|
<path id="b" d="m27.98 54.66 46.39 46.39-63.31 22.68c-3.59 1.28-7.05-2.18-5.76-5.76z"/>
|
||||||
|
</defs>
|
||||||
|
<clipPath id="a">
|
||||||
|
<use width="100%" height="100%" xlink:href="#b"/>
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path d="m39.4 123.94c-8.46-1.78-16.1-3.92-23.29-8.95-6.74-4.71-13.66-11.78-16.33-19.71-2.08-6.18-11.36-1.8-7.97 3.36 5.52 8.4 11.16 15.77 19.73 21.31 7.8 5.05 17.82 8.93 27.23 8.69 2.59-0.07 3.36-4.12 0.63-4.7z"/>
|
||||||
|
</g>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path d="m51.07 113.71c-8.46-1.78-16.1-3.92-23.29-8.95-6.74-4.71-13.66-11.78-16.33-19.71-2.08-6.18-11.36-1.8-7.97 3.36 5.52 8.4 11.16 15.77 19.73 21.31 7.8 5.05 17.82 8.93 27.23 8.69 2.6-0.07 3.36-4.13 0.63-4.7z"/>
|
||||||
|
</g>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path d="m76.71 106.66c-12.95-2.49-24.54-5.73-35.55-13.37-10.36-7.19-20.33-17.69-24.86-29.64-2.27-5.98-11.16-2.02-7.97 3.36 7.39 12.46 16.01 23.17 28.23 31.23 11.23 7.41 25.85 13.37 39.52 13.12 2.59-0.05 3.37-4.17 0.63-4.7z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path d="m35.57 57.28c9.2175 1.8218 16.207 9.1337 21.496 14.423 13.01 13.01 17.945 23.085 14.474 25.007-8.0418 4.4531-19.213-8.8965-23.493-13.181-13.01-13.01-17.947-22.649-15.137-25.449m0.66-5.8c-2.01 0-3.64 0.54-4.78 1.68-4.97 4.97 1.49 19.5 14.43 32.45 9.98 9.98 20.91 16.11 27.66 16.11 2.01 0 3.64-0.54 4.78-1.68 4.97-4.97-1.49-19.5-14.43-32.45-9.98-9.98-20.9-16.11-27.66-16.11z"/>
|
||||||
|
</g>
|
||||||
|
<polygon points="20.39 25.85 15.71 26.72 11.75 16.74 18.47 15.49"/>
|
||||||
|
<polygon points="52.22 5.16 56.65 4 61.17 13.31 54.8 14.98"/>
|
||||||
|
<polygon points="108.97 18.61 111.86 22.73 104 30.92 99.85 25"/>
|
||||||
|
<path d="m60.83 95.45c3.1-7.97 8.61-12.19 17.53-12.3 9.08-0.11 23.89 5.35 24.6 16.07 0-1.64 0-3.27 0.01-4.91-0.7 3.91-4.75 5.54-8.42 4.7-3.9-0.89-6.46-4.17-6.96-8.02 0 1.64 0 3.27 0.01 4.91 0.41-8.89 9.96-11.79 17.47-11.68 7.84 0.12 13.44 5.39 17.73 11.45-0.77-1.09 0.8-3.87 0-5-4.51-6.36-10.34-11.61-18.57-11.46-6.69 0.13-15.43 2.68-16.58 10.35-0.39 2.62-0.48 6.55 0.51 9.02 2.03 5.09 12.11 8.84 14.58 1.99 3.56-9.87-6.38-18.08-14.62-20.79-6.16-2.02-13.22-2.44-19.21 0.42-4.45 2.13-6.38 5.85-8.09 10.24-0.56 1.47 0.56 3.58 0.01 5.01z"/>
|
||||||
|
<path d="m71.16 65.22c3.5 1.86 7.48 4.44 11.45 2.32 2.29-1.23 3.47-3.57 4.44-5.87 2.22-5.25 3.25-8.25 9.34-5.45 3.58 1.64 11.87 7.07 13.38 0.12 0.78-3.61-0.5-7.45-0.69-11 0 1.64 0 3.27-0.01 4.91 0.91-6.28 10.05-4.1 13.91-2.43-0.58-0.25 0.64-4.72 0-5-4.17-1.81-13.12-3.8-13.92 2.77-0.4 3.29 0.42 6.5 0.76 9.73 0-1.64 0-3.27-0.01-4.91-0.56 11.37-15.22-3.27-19.74 0.15-2.51 1.9-2.8 6.55-4.49 9.09-3.8 5.73-9.4 3.26-14.43 0.58 0.67 0.34-0.71 4.61 0.01 4.99z"/>
|
||||||
|
<path d="m34.79 63.81c6.64-0.72 8.01-7.46 6.97-13.04-1.49-8.01-13.26-8.73-14-16.54 0 1.64 0 3.27 0.01 4.91 0.24-4.21 3.5-7.19 6.93-9.13 3.18-1.79 4.95-3.96 5.37-7.81 0.59-5.5-1.21-9.32-6.26-12.17 0.69 0.39-0.74 4.58 0 5 2.52 1.42 5.95 4.07 6.26 7.17v-5c-1.12 6.35-4.44 6.26-8.53 9.91-3.08 2.75-3.8 5.76-3.8 9.62 0 3.69 0.89 6.05 3.99 8.44 4.28 3.29 9.11 5.33 10.13 11.23 0-1.64 0-3.27-0.01-4.91-0.19 4.14-3.06 6.89-7.07 7.32-0.21 0.02 0.15 4.98 0.01 5z"/>
|
||||||
|
<path d="m43.73 80.2c5.3 2.27 12.95-2.87 14.41-7.96 0.73-2.53 0.78-6.18 0.44-8.8-0.48-3.71-3.58-6.08-4.94-9.42-1.09-2.68-0.45-4.97 1.1-7.86 2.5-4.65 13.7-11.7 15.52-2.67 0-1.55-0.01-3.11-0.01-4.66-0.04 2.86-1.76 5.08-4.8 4.49-2.96-0.57-4.25-3.27-4.64-5.96 0.01 1.42 0.01 2.85 0.02 4.27 0.16-12.17 13.35-16.69 23.37-17.33 0.14-0.01-0.07-5 0-5-12.76 0.81-23.41 6.79-23.41 20.56 0 3.68 1.02 9.04 5.96 8.56 4.04-0.39 3.64-5.1 3.54-8.1-0.14-4.15-2.95-7.01-7.49-5.9-5.2 1.28-8.7 6.36-9.73 11.35-0.55 2.66-0.48 5.59-0.35 8.3 0.26 5.77 4.96 9.01 5.86 14.36 0-1.64 0-3.27-0.01-4.91-0.3 4.27-1.71 7.38-5.45 9.87-2.54 1.69-6.42 3.07-9.4 1.79 0.58 0.26-0.63 4.75 0.01 5.02z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.2 KiB |
|
@ -19,16 +19,16 @@
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="sign_in_box">
|
<object class="GtkBox" id="sign_in_jid_box">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="margin">20</property>
|
<property name="margin">20</property>
|
||||||
<property name="margin-start">50</property>
|
<property name="margin-start">50</property>
|
||||||
<property name="margin-end">50</property>
|
<property name="margin-end">50</property>
|
||||||
|
<property name="spacing">20</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="label" translatable="yes">Sign in</property>
|
<property name="label" translatable="yes">Sign in</property>
|
||||||
<property name="margin-bottom">10</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="scale" value="1.3"/>
|
<attribute name="scale" value="1.3"/>
|
||||||
|
@ -57,6 +57,156 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="sign_in_jid_error_label">
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="margin-top">7</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="0.9"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="sign_in_jid_serverlist_button">
|
||||||
|
<property name="label" translatable="yes">Create account</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">start</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="sign_in_jid_continue_button">
|
||||||
|
<property name="sensitive">False</property>
|
||||||
|
<property name="can_default">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="text-button"/>
|
||||||
|
<class name="suggested-action"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStack" id="sign_in_jid_continue_stack">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Next</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">label</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinner">
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">spinner</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">login_jid</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="sign_in_tls_box">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="margin-top">30</property>
|
||||||
|
<property name="margin-bottom">20</property>
|
||||||
|
<property name="margin-start">50</property>
|
||||||
|
<property name="margin-end">50</property>
|
||||||
|
<property name="spacing">20</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon-name">channel-insecure-symbolic</property>
|
||||||
|
<property name="icon-size">4</property>
|
||||||
|
<property name="pixel-size">72</property>
|
||||||
|
<property name="margin-top">10</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Could not establish a secure connection</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="1.1"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="sign_in_tls_label">
|
||||||
|
<property name="justify">fill</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="use-markup">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="sign_in_tls_back_button">
|
||||||
|
<property name="label" translatable="yes">Back</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">start</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">tls_error</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="sign_in_password_box">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="margin">20</property>
|
||||||
|
<property name="margin-start">50</property>
|
||||||
|
<property name="margin-end">50</property>
|
||||||
|
<property name="spacing">20</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="sign_in_password_title">
|
||||||
|
<property name="label">Sign in</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="1.3"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="label" translatable="yes">Password</property>
|
<property name="label" translatable="yes">Password</property>
|
||||||
|
@ -79,8 +229,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel" id="sign_in_password_error_label">
|
||||||
<property name="label" translatable="yes">Local alias</property>
|
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="margin-top">7</property>
|
<property name="margin-top">7</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -89,24 +238,34 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<!--<child>-->
|
||||||
<object class="GtkEntry" id="alias_entry">
|
<!--<object class="GtkLabel">-->
|
||||||
<property name="activates_default">True</property>
|
<!--<property name="label" translatable="yes">Local alias</property>-->
|
||||||
<property name="hexpand">True</property>
|
<!--<property name="xalign">0</property>-->
|
||||||
<property name="width_request">200</property>
|
<!--<property name="margin-top">7</property>-->
|
||||||
<property name="visible">True</property>
|
<!--<property name="visible">True</property>-->
|
||||||
</object>
|
<!--<attributes>-->
|
||||||
</child>
|
<!--<attribute name="scale" value="0.9"/>-->
|
||||||
|
<!--</attributes>-->
|
||||||
|
<!--</object>-->
|
||||||
|
<!--</child>-->
|
||||||
|
<!--<child>-->
|
||||||
|
<!--<object class="GtkEntry" id="alias_entry">-->
|
||||||
|
<!--<property name="activates_default">True</property>-->
|
||||||
|
<!--<property name="hexpand">True</property>-->
|
||||||
|
<!--<property name="width_request">200</property>-->
|
||||||
|
<!--<property name="visible">True</property>-->
|
||||||
|
<!--</object>-->
|
||||||
|
<!--</child>-->
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="orientation">horizontal</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="margin-top">20</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="serverlist_button">
|
<object class="GtkButton" id="sign_in_password_back_button">
|
||||||
<property name="label" translatable="yes">Create account</property>
|
<property name="label" translatable="yes">Back</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -114,14 +273,38 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="sign_in_continue">
|
<object class="GtkButton" id="sign_in_password_continue_button">
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="label" translatable="yes">Save</property>
|
|
||||||
<property name="sensitive">False</property>
|
<property name="sensitive">False</property>
|
||||||
|
<property name="can_default">True</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<style>
|
<style>
|
||||||
|
<class name="text-button"/>
|
||||||
<class name="suggested-action"/>
|
<class name="suggested-action"/>
|
||||||
</style>
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStack" id="sign_in_password_continue_stack">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Connect</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">label</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinner">
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">spinner</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
|
@ -131,7 +314,7 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="name">login</property>
|
<property name="name">login_password</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -335,6 +518,79 @@
|
||||||
<property name="name">form</property>
|
<property name="name">form</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="success_box">
|
||||||
|
<property name="margin">50</property>
|
||||||
|
<property name="margin-top">5</property>
|
||||||
|
<property name="margin-bottom">5</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">10</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon-name">dino-party-popper-symbolic</property>
|
||||||
|
<property name="icon-size">4</property>
|
||||||
|
<property name="pixel-size">72</property>
|
||||||
|
<property name="margin-bottom">10</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">All set up!</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
|
||||||
|
<attribute name="scale" value="1.3"/>
|
||||||
|
</attributes>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="success_description">
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="margin">5</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="use-markup">True</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="margin-top">20</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="success_continue_button">
|
||||||
|
<property name="can_default">True</property>
|
||||||
|
<property name="label" translatable="yes">Finish</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="text-button"/>
|
||||||
|
<class name="suggested-action"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">success</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -22,6 +22,18 @@
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="title_label">
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label"/>
|
||||||
|
</style>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="1.3"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label">
|
<object class="GtkLabel" id="label">
|
||||||
<property name="xalign">0.5</property>
|
<property name="xalign">0.5</property>
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
||||||
activate.connect(() => {
|
activate.connect(() => {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
create_set_app_menu();
|
create_set_app_menu();
|
||||||
window = new UnifiedWindow(this, stream_interactor);
|
window = new UnifiedWindow(this, stream_interactor, db);
|
||||||
notifications = new Notifications(stream_interactor, window);
|
notifications = new Notifications(stream_interactor, window);
|
||||||
notifications.start();
|
notifications.start();
|
||||||
notifications.conversation_selected.connect((conversation) => window.on_conversation_selected(conversation));
|
notifications.conversation_selected.connect((conversation) => window.on_conversation_selected(conversation));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Gee;
|
using Gee;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using Pango;
|
||||||
|
|
||||||
using Dino.Entities;
|
using Dino.Entities;
|
||||||
using Xmpp;
|
using Xmpp;
|
||||||
|
@ -16,13 +17,28 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
[GtkChild] private Revealer notification_revealer;
|
[GtkChild] private Revealer notification_revealer;
|
||||||
[GtkChild] private Label notification_label;
|
[GtkChild] private Label notification_label;
|
||||||
|
|
||||||
// Sign in
|
// Sign in - JID
|
||||||
[GtkChild] private Box sign_in_box;
|
[GtkChild] private Box sign_in_jid_box;
|
||||||
|
[GtkChild] private Label sign_in_jid_error_label;
|
||||||
[GtkChild] private Entry jid_entry;
|
[GtkChild] private Entry jid_entry;
|
||||||
[GtkChild] private Entry alias_entry;
|
[GtkChild] private Stack sign_in_jid_continue_stack;
|
||||||
|
[GtkChild] private Button sign_in_jid_continue_button;
|
||||||
|
[GtkChild] private Button sign_in_jid_serverlist_button;
|
||||||
|
|
||||||
|
// Sign in - TLS error
|
||||||
|
[GtkChild] private Box sign_in_tls_box;
|
||||||
|
[GtkChild] private Label sign_in_tls_label;
|
||||||
|
[GtkChild] private Stack sign_in_password_continue_stack;
|
||||||
|
[GtkChild] private Button sign_in_tls_back_button;
|
||||||
|
|
||||||
|
// Sign in - Password
|
||||||
|
[GtkChild] private Box sign_in_password_box;
|
||||||
|
[GtkChild] private Label sign_in_password_title;
|
||||||
|
[GtkChild] private Label sign_in_password_error_label;
|
||||||
|
|
||||||
[GtkChild] private Entry password_entry;
|
[GtkChild] private Entry password_entry;
|
||||||
[GtkChild] private Button sign_in_continue;
|
[GtkChild] private Button sign_in_password_continue_button;
|
||||||
[GtkChild] private Button serverlist_button;
|
[GtkChild] private Button sign_in_password_back_button;
|
||||||
|
|
||||||
// Select Server
|
// Select Server
|
||||||
[GtkChild] private Box create_account_box;
|
[GtkChild] private Box create_account_box;
|
||||||
|
@ -41,24 +57,41 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
[GtkChild] private Stack register_form_continue_stack;
|
[GtkChild] private Stack register_form_continue_stack;
|
||||||
[GtkChild] private Button register_form_continue;
|
[GtkChild] private Button register_form_continue;
|
||||||
|
|
||||||
|
// Success
|
||||||
|
[GtkChild] private Box success_box;
|
||||||
|
[GtkChild] private Label success_description;
|
||||||
|
[GtkChild] private Button success_continue_button;
|
||||||
|
|
||||||
private static string[] server_list = new string[]{
|
private static string[] server_list = new string[]{
|
||||||
"5222.de",
|
"5222.de",
|
||||||
"jabber.fr",
|
"jabber.fr",
|
||||||
"movim.eu",
|
"movim.eu",
|
||||||
"yax.im"
|
"yax.im"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private StreamInteractor stream_interactor;
|
||||||
private HashMap<ListBoxRow, string> list_box_jids = new HashMap<ListBoxRow, string>();
|
private HashMap<ListBoxRow, string> list_box_jids = new HashMap<ListBoxRow, string>();
|
||||||
private Jid? server_jid = null;
|
private Jid? server_jid = null;
|
||||||
private Xep.InBandRegistration.Form? form = null;
|
private Xep.InBandRegistration.Form? form = null;
|
||||||
|
|
||||||
public AddAccountDialog(StreamInteractor stream_interactor) {
|
public AddAccountDialog(StreamInteractor stream_interactor) {
|
||||||
|
this.stream_interactor = stream_interactor;
|
||||||
this.title = _("Add Account");
|
this.title = _("Add Account");
|
||||||
|
|
||||||
// Sign in
|
// Sign in - Jid
|
||||||
|
Util.force_error_color(sign_in_jid_error_label);
|
||||||
jid_entry.changed.connect(on_jid_entry_changed);
|
jid_entry.changed.connect(on_jid_entry_changed);
|
||||||
jid_entry.focus_out_event.connect(on_jid_entry_focus_out_event);
|
sign_in_jid_continue_button.clicked.connect(on_sign_in_jid_continue_button_clicked);
|
||||||
sign_in_continue.clicked.connect(on_sign_in_continue_clicked);
|
sign_in_jid_serverlist_button.clicked.connect(show_select_server);
|
||||||
serverlist_button.clicked.connect(show_select_server);
|
|
||||||
|
// Sign in - TLS error
|
||||||
|
sign_in_tls_back_button.clicked.connect(show_sign_in_jid);
|
||||||
|
|
||||||
|
// Sign in - Password
|
||||||
|
Util.force_error_color(sign_in_password_error_label);
|
||||||
|
password_entry.changed.connect(() => { sign_in_password_continue_button.set_sensitive(password_entry.text.length > 0); });
|
||||||
|
sign_in_password_continue_button.clicked.connect(on_sign_in_password_continue_button_clicked);
|
||||||
|
sign_in_password_back_button.clicked.connect(show_sign_in_jid);
|
||||||
|
|
||||||
// Select Server
|
// Select Server
|
||||||
server_entry.changed.connect(() => {
|
server_entry.changed.connect(() => {
|
||||||
|
@ -66,7 +99,7 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
select_server_continue.sensitive = jid != null && jid.localpart == null && jid.resourcepart == null;
|
select_server_continue.sensitive = jid != null && jid.localpart == null && jid.resourcepart == null;
|
||||||
});
|
});
|
||||||
select_server_continue.clicked.connect(on_select_server_continue);
|
select_server_continue.clicked.connect(on_select_server_continue);
|
||||||
login_button.clicked.connect(show_sign_in);
|
login_button.clicked.connect(show_sign_in_jid);
|
||||||
|
|
||||||
foreach (string server in server_list) {
|
foreach (string server in server_list) {
|
||||||
ListBoxRow list_box_row = new ListBoxRow() { visible=true };
|
ListBoxRow list_box_row = new ListBoxRow() { visible=true };
|
||||||
|
@ -79,16 +112,49 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
register_form_continue.clicked.connect(on_register_form_continue_clicked);
|
register_form_continue.clicked.connect(on_register_form_continue_clicked);
|
||||||
register_form_back.clicked.connect(show_select_server);
|
register_form_back.clicked.connect(show_select_server);
|
||||||
|
|
||||||
show_sign_in();
|
// Success
|
||||||
|
success_continue_button.clicked.connect(() => close());
|
||||||
|
|
||||||
|
show_sign_in_jid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_sign_in() {
|
private void show_sign_in_jid() {
|
||||||
sign_in_box.visible = true;
|
sign_in_jid_box.visible = true;
|
||||||
stack.visible_child_name = "login";
|
stack.visible_child_name = "login_jid";
|
||||||
|
sign_in_tls_box.visible = false;
|
||||||
|
sign_in_password_box.visible = false;
|
||||||
create_account_box.visible = false;
|
create_account_box.visible = false;
|
||||||
register_box.visible = false;
|
register_box.visible = false;
|
||||||
set_default(sign_in_continue);
|
success_box.visible = false;
|
||||||
animate_window_resize(sign_in_box);
|
set_default(sign_in_jid_continue_button);
|
||||||
|
|
||||||
|
sign_in_jid_error_label.label = "";
|
||||||
|
animate_window_resize(sign_in_jid_box);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void show_tls_error() {
|
||||||
|
sign_in_tls_box.visible = true;
|
||||||
|
stack.visible_child_name = "tls_error";
|
||||||
|
sign_in_jid_box.visible = false;
|
||||||
|
sign_in_password_box.visible = false;
|
||||||
|
create_account_box.visible = false;
|
||||||
|
register_box.visible = false;
|
||||||
|
success_box.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void show_sign_in_password() {
|
||||||
|
sign_in_password_box.visible = true;
|
||||||
|
stack.visible_child_name = "login_password";
|
||||||
|
sign_in_jid_box.visible = false;
|
||||||
|
sign_in_tls_box.visible = false;
|
||||||
|
create_account_box.visible = false;
|
||||||
|
register_box.visible = false;
|
||||||
|
success_box.visible = false;
|
||||||
|
set_default(sign_in_password_continue_button);
|
||||||
|
|
||||||
|
sign_in_password_error_label.label = "";
|
||||||
|
sign_in_password_title.label = _("Sign in to %s").printf(jid_entry.text);
|
||||||
|
animate_window_resize(sign_in_password_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_select_server() {
|
private void show_select_server() {
|
||||||
|
@ -102,8 +168,10 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
|
|
||||||
create_account_box.visible = true;
|
create_account_box.visible = true;
|
||||||
stack.visible_child_name = "server";
|
stack.visible_child_name = "server";
|
||||||
sign_in_box.visible = false;
|
sign_in_jid_box.visible = false;
|
||||||
|
sign_in_tls_box.visible = false;
|
||||||
register_box.visible = false;
|
register_box.visible = false;
|
||||||
|
success_box.visible = false;
|
||||||
|
|
||||||
animate_window_resize(create_account_box);
|
animate_window_resize(create_account_box);
|
||||||
}
|
}
|
||||||
|
@ -111,40 +179,88 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
private void show_register_form() {
|
private void show_register_form() {
|
||||||
register_box.visible = true;
|
register_box.visible = true;
|
||||||
stack.visible_child_name = "form";
|
stack.visible_child_name = "form";
|
||||||
sign_in_box.visible = false;
|
sign_in_jid_box.visible = false;
|
||||||
|
sign_in_tls_box.visible = false;
|
||||||
|
sign_in_password_box.visible = false;
|
||||||
create_account_box.visible = false;
|
create_account_box.visible = false;
|
||||||
|
success_box.visible = false;
|
||||||
|
|
||||||
set_default(register_form_continue);
|
set_default(register_form_continue);
|
||||||
animate_window_resize(register_box);
|
animate_window_resize(register_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void show_success() {
|
||||||
|
success_box.visible = true;
|
||||||
|
stack.visible_child_name = "success";
|
||||||
|
sign_in_jid_box.visible = false;
|
||||||
|
sign_in_tls_box.visible = false;
|
||||||
|
sign_in_password_box.visible = false;
|
||||||
|
create_account_box.visible = false;
|
||||||
|
register_box.visible = false;
|
||||||
|
success_description.label = _("You can now start using %s").printf("<b>" + Markup.escape_text(jid_entry.text) + "</b>");
|
||||||
|
|
||||||
|
set_default(success_continue_button);
|
||||||
|
}
|
||||||
|
|
||||||
private void on_jid_entry_changed() {
|
private void on_jid_entry_changed() {
|
||||||
Jid? jid = Jid.parse(jid_entry.text);
|
Jid? jid = Jid.parse(jid_entry.text);
|
||||||
if (jid != null && jid.localpart != null && jid.resourcepart == null) {
|
if (jid != null && jid.localpart != null && jid.resourcepart == null) {
|
||||||
sign_in_continue.set_sensitive(true);
|
sign_in_jid_continue_button.set_sensitive(true);
|
||||||
jid_entry.secondary_icon_name = null;
|
jid_entry.secondary_icon_name = null;
|
||||||
} else {
|
} else {
|
||||||
sign_in_continue.set_sensitive(false);
|
sign_in_jid_continue_button.set_sensitive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool on_jid_entry_focus_out_event() {
|
private async void on_sign_in_jid_continue_button_clicked() {
|
||||||
Jid? jid = Jid.parse(jid_entry.text);
|
Jid jid = new Jid(jid_entry.get_text());
|
||||||
if (jid == null || jid.localpart == null || jid.resourcepart != null) {
|
sign_in_jid_continue_stack.visible_child_name = "spinner";
|
||||||
jid_entry.secondary_icon_name = "dialog-warning-symbolic";
|
Register.ServerAvailabilityReturn server_status = yield stream_interactor.get_module(Register.IDENTITY).check_server_availability(jid);
|
||||||
jid_entry.set_icon_tooltip_text(EntryIconPosition.SECONDARY, _("JID should be of the form “user@example.com”"));
|
sign_in_jid_continue_stack.visible_child_name = "label";
|
||||||
|
if (server_status.available) {
|
||||||
|
show_sign_in_password();
|
||||||
} else {
|
} else {
|
||||||
jid_entry.secondary_icon_name = null;
|
if (server_status.error_flags != null) {
|
||||||
|
string error_desc = "The server could not prove that it is %s.".printf("<b>" + jid.domainpart + "</b>");
|
||||||
|
if (TlsCertificateFlags.UNKNOWN_CA in server_status.error_flags) {
|
||||||
|
error_desc += " " + "Its security certificate is not trusted by your computer's operating system.";
|
||||||
|
} else if (TlsCertificateFlags.BAD_IDENTITY in server_status.error_flags) {
|
||||||
|
error_desc += " " + "Its security certificate is issued to another domain.";
|
||||||
|
} else if (TlsCertificateFlags.NOT_ACTIVATED in server_status.error_flags) {
|
||||||
|
error_desc += " " + "Its security certificate will only become valid in the future.";
|
||||||
|
} else if (TlsCertificateFlags.EXPIRED in server_status.error_flags) {
|
||||||
|
error_desc += " " + "Its security certificate is expired.";
|
||||||
|
}
|
||||||
|
sign_in_tls_label.label = error_desc;
|
||||||
|
show_tls_error();
|
||||||
|
} else {
|
||||||
|
sign_in_jid_error_label.label = _("Could not connect to %s").printf(jid.domainpart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_sign_in_continue_clicked() {
|
private async void on_sign_in_password_continue_button_clicked() {
|
||||||
Jid jid = new Jid(jid_entry.get_text());
|
Jid jid = new Jid(jid_entry.get_text());
|
||||||
string password = password_entry.get_text();
|
string password = password_entry.get_text();
|
||||||
string alias = alias_entry.get_text();
|
Account account = new Account(jid, null, password, null);
|
||||||
store_account(jid, password, alias);
|
|
||||||
close();
|
sign_in_password_continue_stack.visible_child_name = "spinner";
|
||||||
|
ConnectionManager.ConnectionError.Source? error = yield stream_interactor.get_module(Register.IDENTITY).add_check_account(account);
|
||||||
|
sign_in_password_continue_stack.visible_child_name = "label";
|
||||||
|
|
||||||
|
if (error != null) {
|
||||||
|
switch (error) {
|
||||||
|
case ConnectionManager.ConnectionError.Source.SASL:
|
||||||
|
sign_in_password_error_label.label = _("Wrong username or password");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sign_in_password_error_label.label = "Something went wrong";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
show_success();
|
||||||
|
added(account);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_select_server_continue() {
|
private void on_select_server_continue() {
|
||||||
|
@ -209,7 +325,7 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
try {
|
try {
|
||||||
AppInfo.launch_default_for_uri(form.oob, null);
|
AppInfo.launch_default_for_uri(form.oob, null);
|
||||||
} catch (Error e) { }
|
} catch (Error e) { }
|
||||||
show_sign_in();
|
show_sign_in_jid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,18 +343,14 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
case "password": password = field.get_value_string(); break;
|
case "password": password = field.get_value_string(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
store_account(new Jid(username + "@" + server_jid.domainpart), password, "");
|
Account account = new Account(new Jid(username + "@" + server_jid.domainpart), null, password, null);
|
||||||
close();
|
show_success();
|
||||||
|
added(account);
|
||||||
} else {
|
} else {
|
||||||
display_notification(error);
|
display_notification(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void store_account(Jid jid, string password, string? alias) {
|
|
||||||
Account account = new Account(jid, null, password, alias);
|
|
||||||
added(account);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void display_notification(string text) {
|
private void display_notification(string text) {
|
||||||
notification_label.label = text;
|
notification_label.label = text;
|
||||||
notification_revealer.set_reveal_child(true);
|
notification_revealer.set_reveal_child(true);
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Dino.Ui {
|
||||||
|
|
||||||
public class UnifiedWindow : Gtk.Window {
|
public class UnifiedWindow : Gtk.Window {
|
||||||
|
|
||||||
|
private WelcomePlceholder welcome_placeholder = new WelcomePlceholder() { visible=true };
|
||||||
private NoAccountsPlaceholder accounts_placeholder = new NoAccountsPlaceholder() { visible=true };
|
private NoAccountsPlaceholder accounts_placeholder = new NoAccountsPlaceholder() { visible=true };
|
||||||
private NoConversationsPlaceholder conversations_placeholder = new NoConversationsPlaceholder() { visible=true };
|
private NoConversationsPlaceholder conversations_placeholder = new NoConversationsPlaceholder() { visible=true };
|
||||||
private ChatInput.View chat_input;
|
private ChatInput.View chat_input;
|
||||||
|
@ -28,11 +29,13 @@ public class UnifiedWindow : Gtk.Window {
|
||||||
private StreamInteractor stream_interactor;
|
private StreamInteractor stream_interactor;
|
||||||
private Conversation? conversation;
|
private Conversation? conversation;
|
||||||
private Application app;
|
private Application app;
|
||||||
|
private Database db;
|
||||||
|
|
||||||
public UnifiedWindow(Application application, StreamInteractor stream_interactor) {
|
public UnifiedWindow(Application application, StreamInteractor stream_interactor, Database db) {
|
||||||
Object(application : application);
|
Object(application : application);
|
||||||
this.stream_interactor = stream_interactor;
|
|
||||||
this.app = application;
|
this.app = application;
|
||||||
|
this.stream_interactor = stream_interactor;
|
||||||
|
this.db = db;
|
||||||
|
|
||||||
restore_window_size();
|
restore_window_size();
|
||||||
|
|
||||||
|
@ -92,6 +95,11 @@ public class UnifiedWindow : Gtk.Window {
|
||||||
stream_interactor.account_removed.connect((account) => { check_stack(); });
|
stream_interactor.account_removed.connect((account) => { check_stack(); });
|
||||||
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(() => check_stack());
|
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(() => check_stack());
|
||||||
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(() => check_stack());
|
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(() => check_stack());
|
||||||
|
welcome_placeholder.primary_button.clicked.connect(() => {
|
||||||
|
ManageAccounts.AddAccountDialog dialog = new ManageAccounts.AddAccountDialog(stream_interactor);
|
||||||
|
dialog.set_transient_for(app.get_active_window());
|
||||||
|
dialog.present();
|
||||||
|
});
|
||||||
accounts_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("accounts", null); });
|
accounts_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("accounts", null); });
|
||||||
conversations_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("add_chat", null); });
|
conversations_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("add_chat", null); });
|
||||||
conversations_placeholder.secondary_button.clicked.connect(() => { get_application().activate_action("add_conference", null); });
|
conversations_placeholder.secondary_button.clicked.connect(() => { get_application().activate_action("add_conference", null); });
|
||||||
|
@ -173,6 +181,7 @@ public class UnifiedWindow : Gtk.Window {
|
||||||
|
|
||||||
private void setup_stack() {
|
private void setup_stack() {
|
||||||
stack.add_named(paned, "main");
|
stack.add_named(paned, "main");
|
||||||
|
stack.add_named(welcome_placeholder, "welcome_placeholder");
|
||||||
stack.add_named(accounts_placeholder, "accounts_placeholder");
|
stack.add_named(accounts_placeholder, "accounts_placeholder");
|
||||||
stack.add_named(conversations_placeholder, "conversations_placeholder");
|
stack.add_named(conversations_placeholder, "conversations_placeholder");
|
||||||
add(stack);
|
add(stack);
|
||||||
|
@ -181,8 +190,13 @@ public class UnifiedWindow : Gtk.Window {
|
||||||
private void check_stack(bool know_exists = false) {
|
private void check_stack(bool know_exists = false) {
|
||||||
ArrayList<Account> accounts = stream_interactor.get_accounts();
|
ArrayList<Account> accounts = stream_interactor.get_accounts();
|
||||||
if (!know_exists && accounts.size == 0) {
|
if (!know_exists && accounts.size == 0) {
|
||||||
|
if (db.get_accounts().size == 0) {
|
||||||
|
stack.set_visible_child_name("welcome_placeholder");
|
||||||
|
set_titlebar(placeholder_headerbar);
|
||||||
|
} else {
|
||||||
stack.set_visible_child_name("accounts_placeholder");
|
stack.set_visible_child_name("accounts_placeholder");
|
||||||
set_titlebar(placeholder_headerbar);
|
set_titlebar(placeholder_headerbar);
|
||||||
|
}
|
||||||
} else if (stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations().size == 0) {
|
} else if (stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations().size == 0) {
|
||||||
stack.set_visible_child_name("conversations_placeholder");
|
stack.set_visible_child_name("conversations_placeholder");
|
||||||
set_titlebar(placeholder_headerbar);
|
set_titlebar(placeholder_headerbar);
|
||||||
|
@ -228,25 +242,40 @@ public class UnifiedWindow : Gtk.Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class WelcomePlceholder : UnifiedWindowPlaceholder {
|
||||||
|
public WelcomePlceholder() {
|
||||||
|
title_label.label = _("Welcome to Dino!");
|
||||||
|
label.label = _("Communicate happieness.");
|
||||||
|
primary_button.label = _("Setup account");
|
||||||
|
title_label.visible = true;
|
||||||
|
secondary_button.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class NoAccountsPlaceholder : UnifiedWindowPlaceholder {
|
public class NoAccountsPlaceholder : UnifiedWindowPlaceholder {
|
||||||
public NoAccountsPlaceholder() {
|
public NoAccountsPlaceholder() {
|
||||||
label.label = _("No active accounts");
|
title_label.label = _("No active accounts");
|
||||||
primary_button.label = _("Manage accounts");
|
primary_button.label = _("Manage accounts");
|
||||||
|
title_label.visible = true;
|
||||||
|
label.visible = false;
|
||||||
secondary_button.visible = false;
|
secondary_button.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NoConversationsPlaceholder : UnifiedWindowPlaceholder {
|
public class NoConversationsPlaceholder : UnifiedWindowPlaceholder {
|
||||||
public NoConversationsPlaceholder() {
|
public NoConversationsPlaceholder() {
|
||||||
label.label = _("No active conversations");
|
title_label.label = _("No active conversations");
|
||||||
primary_button.label = _("Start Conversation");
|
primary_button.label = _("Start Conversation");
|
||||||
secondary_button.label = _("Join Channel");
|
secondary_button.label = _("Join Channel");
|
||||||
|
title_label.visible = true;
|
||||||
|
label.visible = false;
|
||||||
secondary_button.visible = true;
|
secondary_button.visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[GtkTemplate (ui = "/im/dino/Dino/unified_window_placeholder.ui")]
|
[GtkTemplate (ui = "/im/dino/Dino/unified_window_placeholder.ui")]
|
||||||
public class UnifiedWindowPlaceholder : Box {
|
public class UnifiedWindowPlaceholder : Box {
|
||||||
|
[GtkChild] public Label title_label;
|
||||||
[GtkChild] public Label label;
|
[GtkChild] public Label label;
|
||||||
[GtkChild] public Button primary_button;
|
[GtkChild] public Button primary_button;
|
||||||
[GtkChild] public Button secondary_button;
|
[GtkChild] public Button secondary_button;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public static string get_display_name(StreamInteractor stream_interactor, Jid ji
|
||||||
} else {
|
} else {
|
||||||
if (jid.equals_bare(account.bare_jid)) {
|
if (jid.equals_bare(account.bare_jid)) {
|
||||||
if (account.alias == null || account.alias == "") {
|
if (account.alias == null || account.alias == "") {
|
||||||
return account.bare_jid.to_string();
|
return _("Me");
|
||||||
} else {
|
} else {
|
||||||
return account.alias;
|
return account.alias;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Xmpp.Tls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool on_invalid_certificate(TlsCertificate peer_cert, TlsCertificateFlags errors) {
|
public bool on_invalid_certificate(TlsCertificate peer_cert, TlsCertificateFlags errors) {
|
||||||
string error_str = "";
|
string error_str = "";
|
||||||
foreach (var f in new TlsCertificateFlags[]{TlsCertificateFlags.UNKNOWN_CA, TlsCertificateFlags.BAD_IDENTITY,
|
foreach (var f in new TlsCertificateFlags[]{TlsCertificateFlags.UNKNOWN_CA, TlsCertificateFlags.BAD_IDENTITY,
|
||||||
TlsCertificateFlags.NOT_ACTIVATED, TlsCertificateFlags.EXPIRED, TlsCertificateFlags.REVOKED,
|
TlsCertificateFlags.NOT_ACTIVATED, TlsCertificateFlags.EXPIRED, TlsCertificateFlags.REVOKED,
|
||||||
|
@ -68,6 +68,7 @@ namespace Xmpp.Tls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
warning(@"Tls Certificate Errors: $(error_str)");
|
warning(@"Tls Certificate Errors: $(error_str)");
|
||||||
|
invalid_certificate(peer_cert, errors);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class TlsConnectionProvider : ConnectionProvider {
|
||||||
try {
|
try {
|
||||||
IOStream? io_stream = yield client.connect_to_host_async(srv_target.get_hostname(), srv_target.get_port());
|
IOStream? io_stream = yield client.connect_to_host_async(srv_target.get_hostname(), srv_target.get_port());
|
||||||
TlsConnection tls_connection = TlsClientConnection.new(io_stream, new NetworkAddress(stream.remote_name.to_string(), srv_target.get_port()));
|
TlsConnection tls_connection = TlsClientConnection.new(io_stream, new NetworkAddress(stream.remote_name.to_string(), srv_target.get_port()));
|
||||||
tls_connection.accept_certificate.connect(Tls.Module.on_invalid_certificate);
|
tls_connection.accept_certificate.connect(stream.get_module(Tls.Module.IDENTITY).on_invalid_certificate);
|
||||||
stream.add_flag(new Tls.Flag() { finished=true });
|
stream.add_flag(new Tls.Flag() { finished=true });
|
||||||
return tls_connection;
|
return tls_connection;
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
|
|
Loading…
Reference in a new issue