[geary/mjog/invert-folder-class-hierarchy] engine: Add RemoteFolder.is_connected property
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/invert-folder-class-hierarchy] engine: Add RemoteFolder.is_connected property
- Date: Sun, 7 Mar 2021 10:29:18 +0000 (UTC)
commit 51da5e82323512dbba3a5e6cd817e2011a2df125
Author: Michael Gratton <mike vee net>
Date: Thu Mar 4 21:20:23 2021 +1100
engine: Add RemoteFolder.is_connected property
src/engine/api/geary-remote-folder.vala | 10 ++++++++++
src/engine/imap-engine/imap-engine-minimal-folder.vala | 7 +++++++
test/mock/mock-remote-folder.vala | 5 +++++
3 files changed, 22 insertions(+)
---
diff --git a/src/engine/api/geary-remote-folder.vala b/src/engine/api/geary-remote-folder.vala
index b58485ade..87ea594dc 100644
--- a/src/engine/api/geary-remote-folder.vala
+++ b/src/engine/api/geary-remote-folder.vala
@@ -91,6 +91,16 @@ public interface Geary.RemoteFolder : Folder {
}
+ /**
+ * Determines if there is an open network connection to the remote.
+ *
+ * Note that this property reflects the engine's best current
+ * understanding of whether a remote connection is currently
+ * available. It may be inaccurate due to changing network
+ * conditions and is at best treated as advisory.
+ */
+ public abstract bool is_connected { get; }
+
/**
* Last known properties of this folder's remote mailbox.
*
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index 30d649ccf..d599d43da 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -78,6 +78,11 @@ private class Geary.ImapEngine.MinimalFolder : BaseObject,
get { return this.local_folder.properties; }
}
+ /** {@inheritDoc} */
+ public bool is_connected {
+ get { return this.remote_session != null; }
+ }
+
/** {@inheritDoc} */
public bool is_fully_expanded {
get { return this._is_fully_expanded; }
@@ -455,6 +460,7 @@ private class Geary.ImapEngine.MinimalFolder : BaseObject,
// All done, can now hook up the session to the folder
this.remote_session = session;
session.disconnected.connect(on_remote_disconnected);
+ notify_property("is-connected");
// Enable IDLE now that the local and remote folders are in
// sync. Can't do this earlier since we might get untagged
@@ -824,6 +830,7 @@ private class Geary.ImapEngine.MinimalFolder : BaseObject,
this.update_flags_timer.reset();
this.replay_queue.stop_remote();
this.remote_session = null;
+ notify_property("is-connected");
session.appended.disconnect(on_remote_appended);
session.updated.disconnect(on_remote_updated);
diff --git a/test/mock/mock-remote-folder.vala b/test/mock/mock-remote-folder.vala
index 08907fd55..1be3865b8 100644
--- a/test/mock/mock-remote-folder.vala
+++ b/test/mock/mock-remote-folder.vala
@@ -63,6 +63,11 @@ public class Mock.RemoteFolder : GLib.Object,
get { return this._used_as; }
}
+ public bool is_connected {
+ get { return this._connected; }
+ }
+ private bool _connected = false;
+
public bool is_fully_expanded {
get { return this._is_fully_expanded; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]