[geary/mjog/986-namespace-assert: 2/4] Geary.Imap.SessionObject: Ensure the session is connected when accessed
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/986-namespace-assert: 2/4] Geary.Imap.SessionObject: Ensure the session is connected when accessed
- Date: Tue, 22 Sep 2020 23:25:58 +0000 (UTC)
commit 2b79942beba44e85dd62c1d031417af5ef219add
Author: Michael Gratton <mike vee net>
Date: Wed Sep 23 08:48:45 2020 +1000
Geary.Imap.SessionObject: Ensure the session is connected when accessed
Ensure the client session is connected as well as non-null when being
accessed, so that if being logged out it is also treated as being
disconnected.
src/engine/imap/api/imap-session-object.vala | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/engine/imap/api/imap-session-object.vala b/src/engine/imap/api/imap-session-object.vala
index 4937d4626..ee1ac09fb 100644
--- a/src/engine/imap/api/imap-session-object.vala
+++ b/src/engine/imap/api/imap-session-object.vala
@@ -83,16 +83,20 @@ public abstract class Geary.Imap.SessionObject : BaseObject, Logging.Source {
}
/**
- * Obtains IMAP session the server for use by this object.
+ * Returns a valid IMAP client session for use by this object.
*
- * @throws ImapError.NOT_CONNECTED if the session with the server
- * server has been dropped via {@link close}, or because
- * the connection was lost.
+ * @throws ImapError.NOT_CONNECTED if the client session has been
+ * dropped via {@link close}, if the client session is logging out
+ * or has been closed, or because the connection to the server was
+ * lost.
*/
protected ClientSession claim_session()
throws ImapError {
- if (this.session == null) {
- throw new ImapError.NOT_CONNECTED("IMAP object has no session");
+ if (this.session == null ||
+ this.session.get_protocol_state() == NOT_CONNECTED) {
+ throw new ImapError.NOT_CONNECTED(
+ "IMAP object has no session or is not connected"
+ );
}
return this.session;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]