[geary/wip/17-noisy-problem-reports: 7/12] Add and hook up Retry buttons to service status inforbars as apropriate
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/17-noisy-problem-reports: 7/12] Add and hook up Retry buttons to service status inforbars as apropriate
- Date: Tue, 1 Jan 2019 11:30:19 +0000 (UTC)
commit f80d0416a9192591b609cc848f0a22eee8f63e6f
Author: Michael Gratton <mike vee net>
Date: Tue Jan 1 21:26:42 2019 +1100
Add and hook up Retry buttons to service status inforbars as apropriate
src/client/application/geary-controller.vala | 28 +++++++++++
src/client/components/main-window.vala | 28 ++++++++++-
src/engine/api/geary-client-service.vala | 21 ++++++++-
ui/main-window.ui | 69 ++++++++++++++++++++--------
4 files changed, 124 insertions(+), 22 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 3eb6a3d9..15772f40 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -270,6 +270,7 @@ public class GearyController : Geary.BaseObject {
// Create the main window (must be done after creating actions.)
main_window = new MainWindow(this.application);
+ main_window.retry_service_problem.connect(on_retry_service_problem);
main_window.on_shift_key.connect(on_shift_key);
main_window.notify["has-toplevel-focus"].connect(on_has_toplevel_focus);
@@ -998,6 +999,33 @@ public class GearyController : Geary.BaseObject {
report_problem(problem);
}
+ private void on_retry_service_problem(Geary.ClientService.Status type) {
+ AccountContext? context = Geary.traverse(this.accounts.values)
+ .first_matching((ctx) => (
+ ctx.account.current_status.has_service_problem() &&
+ (ctx.account.incoming.current_status == type ||
+ ctx.account.outgoing.current_status == type)
+ )
+ );
+
+ if (context != null) {
+ Geary.Account account = context.account;
+ Geary.ClientService service = account.incoming.current_status == type
+ ? account.incoming
+ : account.outgoing;
+
+ switch (type) {
+ case AUTHENTICATION_FAILED:
+ // Reset so the infobar does not show up again
+ context.authentication_failed = false;
+ break;
+
+ }
+
+ service.restart.begin(context.cancellable);
+ }
+ }
+
private void on_account_status_notify() {
update_account_status();
}
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 25e83078..1fce807d 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -66,11 +66,14 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
private Gtk.InfoBar service_problem_infobar;
[GtkChild]
- private Gtk.InfoBar auth_problem_infobar;
+ private Gtk.InfoBar cert_problem_infobar;
[GtkChild]
- private Gtk.InfoBar cert_problem_infobar;
+ private Gtk.InfoBar auth_problem_infobar;
+
+ /** Fired when the user requests an account status be retried. */
+ public signal void retry_service_problem(Geary.ClientService.Status problem);
/** Fired when the shift key is pressed or released. */
public signal void on_shift_key(bool pressed);
@@ -522,6 +525,27 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
update_infobar_frame();
}
+ [GtkCallback]
+ private void on_service_problem_retry() {
+ this.service_problem_infobar.hide();
+ update_infobar_frame();
+ retry_service_problem(Geary.ClientService.Status.CONNECTION_FAILED);
+ }
+
+ [GtkCallback]
+ private void on_cert_problem_retry() {
+ this.cert_problem_infobar.hide();
+ update_infobar_frame();
+ retry_service_problem(Geary.ClientService.Status.TLS_VALIDATION_FAILED);
+ }
+
+ [GtkCallback]
+ private void on_auth_problem_retry() {
+ this.auth_problem_infobar.hide();
+ update_infobar_frame();
+ retry_service_problem(Geary.ClientService.Status.AUTHENTICATION_FAILED);
+ }
+
[GtkCallback]
private void on_info_bar_container_remove() {
update_infobar_frame();
diff --git a/src/engine/api/geary-client-service.vala b/src/engine/api/geary-client-service.vala
index 5e38ed12..e0e76941 100644
--- a/src/engine/api/geary-client-service.vala
+++ b/src/engine/api/geary-client-service.vala
@@ -247,7 +247,7 @@ public abstract class Geary.ClientService : BaseObject {
}
/**
- * Starts the service manager running.
+ * Starts the service running.
*
* This may cause the manager to establish connections to the
* network service.
@@ -256,13 +256,30 @@ public abstract class Geary.ClientService : BaseObject {
throws GLib.Error;
/**
- * Stops the service manager running.
+ * Stops the service running.
*
* Any existing connections to the network service will be closed.
*/
public abstract async void stop(GLib.Cancellable? cancellable = null)
throws GLib.Error;
+ /**
+ * Starts the service, stopping it first if running.
+ *
+ * An error will be thrown if the service could not be stopped or
+ * could not be started again. If an error is thrown while
+ * stopping the service, no attempt will be made to start it
+ * again.
+ */
+ public async void restart(GLib.Cancellable? cancellable = null)
+ throws GLib.Error {
+ if (this.is_running) {
+ yield stop(cancellable);
+ }
+
+ yield start(cancellable);
+ }
+
/**
* Called when the network service has become reachable.
*
diff --git a/ui/main-window.ui b/ui/main-window.ui
index 811b886f..e3c88a7e 100644
--- a/ui/main-window.ui
+++ b/ui/main-window.ui
@@ -243,7 +243,18 @@ You will not be able to send or receive email until it is re-connected.</propert
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
- <placeholder/>
+ <object class="GtkButton">
+ <property name="label" translatable="yes" comments="Button label for
retrying an account problem">Retry</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_service_problem_retry" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
@@ -318,7 +329,7 @@ Please check your Internet connection, the server configuration and try again.</
</packing>
</child>
<child>
- <object class="GtkInfoBar" id="auth_problem_infobar">
+ <object class="GtkInfoBar" id="cert_problem_infobar">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="message_type">error</property>
@@ -328,7 +339,18 @@ Please check your Internet connection, the server configuration and try again.</
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
- <placeholder/>
+ <object class="GtkButton">
+ <property name="label" translatable="yes" comments="Button label for
retrying an account problem">Retry</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_cert_problem_retry" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
@@ -346,11 +368,11 @@ Please check your Internet connection, the server configuration and try again.</
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="auth_problem_title">
+ <object class="GtkLabel" id="cert_problem_title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="label" translatable="yes" comments="Infobar title when
one or more accounts have a login error">Login problem</property>
+ <property name="label" translatable="yes" comments="Infobar title when
one or more accounts have a TLS cert validation error">Security problem</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -361,13 +383,13 @@ Please check your Internet connection, the server configuration and try again.</
</packing>
</child>
<child>
- <object class="GtkLabel" id="auth_problem_description">
+ <object class="GtkLabel" id="cert_problem_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes" comments="Label and
tooltip for authentication problem infobar">An account has reported an incorrect login or password.
-Please check your login name and try again.</property>
+ <property name="tooltip_text" translatable="yes" comments="Label and
tooltip for TLS cert validation error infobar">An account has reported an untrusted server.
+Please check the server configuration and try again.</property>
<property name="halign">start</property>
- <property name="label" translatable="yes" comments="Label and tooltip
for authentication problem infobar">An account has reported an incorrect login or password.</property>
+ <property name="label" translatable="yes" comments="Label and tooltip
for TLS cert validation error infobar">An account has reported an untrusted server.</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
</object>
@@ -403,17 +425,28 @@ Please check your login name and try again.</property>
</packing>
</child>
<child>
- <object class="GtkInfoBar" id="cert_problem_infobar">
+ <object class="GtkInfoBar" id="auth_problem_infobar">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="message_type">warning</property>
+ <property name="message_type">error</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
- <placeholder/>
+ <object class="GtkButton">
+ <property name="label" translatable="yes" comments="Button label for
retrying an account problem">Retry</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_auth_problem_retry" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
@@ -431,11 +464,11 @@ Please check your login name and try again.</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="cert_problem_title">
+ <object class="GtkLabel" id="auth_problem_title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="label" translatable="yes" comments="Infobar title when
one or more accounts have a TLS cert validation error">Security problem</property>
+ <property name="label" translatable="yes" comments="Infobar title when
one or more accounts have a login error">Login problem</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -446,13 +479,13 @@ Please check your login name and try again.</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="cert_problem_description">
+ <object class="GtkLabel" id="auth_problem_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes" comments="Label and
tooltip for TLS cert validation error infobar">An account has reported an untrusted server.
-Please check the server configuration and try again.</property>
+ <property name="tooltip_text" translatable="yes" comments="Label and
tooltip for authentication problem infobar">An account has reported an incorrect login or password.
+Please check your login name and try again.</property>
<property name="halign">start</property>
- <property name="label" translatable="yes" comments="Label and tooltip
for TLS cert validation error infobar">An account has reported an untrusted server.</property>
+ <property name="label" translatable="yes" comments="Label and tooltip
for authentication problem infobar">An account has reported an incorrect login or password.</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]