Compare commits
2 Commits
master
...
inhibit-be
Author | SHA1 | Date |
---|---|---|
Xavier Del Campo Romero | 7d075814ea | |
Xavier Del Campo Romero | 78333ce250 |
|
@ -11,6 +11,7 @@ public class ConnectionManager : Object {
|
||||||
public signal void stream_attached_modules(Account account, XmppStream stream);
|
public signal void stream_attached_modules(Account account, XmppStream stream);
|
||||||
public signal void connection_state_changed(Account account, ConnectionState state);
|
public signal void connection_state_changed(Account account, ConnectionState state);
|
||||||
public signal void connection_error(Account account, ConnectionError error);
|
public signal void connection_error(Account account, ConnectionError error);
|
||||||
|
public signal void request_inhibit(bool suspend);
|
||||||
|
|
||||||
public enum ConnectionState {
|
public enum ConnectionState {
|
||||||
CONNECTED,
|
CONNECTED,
|
||||||
|
@ -348,9 +349,10 @@ public class ConnectionManager : Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void on_prepare_for_sleep(bool suspend) {
|
private async void on_prepare_for_sleep(bool suspend) {
|
||||||
foreach (Account account in connections.keys) {
|
request_inhibit(true);
|
||||||
change_connection_state(account, ConnectionState.DISCONNECTED);
|
// foreach (Account account in connections.keys) {
|
||||||
}
|
// change_connection_state(account, ConnectionState.DISCONNECTED);
|
||||||
|
// }
|
||||||
if (suspend) {
|
if (suspend) {
|
||||||
debug("Login1: Device suspended");
|
debug("Login1: Device suspended");
|
||||||
foreach (Account account in connections.keys) {
|
foreach (Account account in connections.keys) {
|
||||||
|
@ -367,6 +369,7 @@ public class ConnectionManager : Object {
|
||||||
debug("Login1: Device un-suspend");
|
debug("Login1: Device un-suspend");
|
||||||
check_reconnects();
|
check_reconnects();
|
||||||
}
|
}
|
||||||
|
request_inhibit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void change_connection_state(Account account, ConnectionState state) {
|
private void change_connection_state(Account account, ConnectionState state) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
||||||
public StreamInteractor stream_interactor { get; set; }
|
public StreamInteractor stream_interactor { get; set; }
|
||||||
public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); }
|
public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); }
|
||||||
public SearchPathGenerator? search_path_generator { get; set; }
|
public SearchPathGenerator? search_path_generator { get; set; }
|
||||||
|
private uint inhibit_cookie;
|
||||||
|
|
||||||
internal static bool print_version = false;
|
internal static bool print_version = false;
|
||||||
private const OptionEntry[] options = {
|
private const OptionEntry[] options = {
|
||||||
|
@ -30,6 +31,22 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
||||||
public Application() throws Error {
|
public Application() throws Error {
|
||||||
Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN);
|
Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN);
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
stream_interactor.connection_manager.request_inhibit.connect((do_inhibit) => {
|
||||||
|
debug(@"requested inhibit [%i]", do_inhibit);
|
||||||
|
|
||||||
|
if (do_inhibit) {
|
||||||
|
inhibit_cookie = inhibit(window, SUSPEND, "Preparing for sleep");
|
||||||
|
|
||||||
|
if (inhibit_cookie == 0) {
|
||||||
|
warning("suspend inhibit request failed or unsupported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (inhibit_cookie != 0) {
|
||||||
|
uninhibit(inhibit_cookie);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Environment.set_application_name("Dino");
|
Environment.set_application_name("Dino");
|
||||||
Window.set_default_icon_name("im.dino.Dino");
|
Window.set_default_icon_name("im.dino.Dino");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue