[geary/wip/actually-imap-logout: 1111/1111] Merge Geary.Imap.ClientSession logout states
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/actually-imap-logout: 1111/1111] Merge Geary.Imap.ClientSession logout states
- Date: Sun, 1 Dec 2019 07:53:51 +0000 (UTC)
commit c080cd56bd3778cbf2d60b15ef9135e0c634b502
Author: Michael Gratton <mike vee net>
Date: Sun Dec 1 17:27:52 2019 +1100
Merge Geary.Imap.ClientSession logout states
Merge LOGGING_OUT and LOGGED_OUT into single LOGOUT state to match
RFC 3501. This leaves CLOSED as the only terminal state, and simplifies
the FSM a bit.
src/engine/imap/transport/imap-client-session.vala | 71 ++++++++++------------
1 file changed, 32 insertions(+), 39 deletions(-)
---
diff --git a/src/engine/imap/transport/imap-client-session.vala
b/src/engine/imap/transport/imap-client-session.vala
index 2806e901..c368ab32 100644
--- a/src/engine/imap/transport/imap-client-session.vala
+++ b/src/engine/imap/transport/imap-client-session.vala
@@ -82,7 +82,7 @@ public class Geary.Imap.ClientSession : BaseObject {
*
* These don't exactly match the states in the IMAP specification. For one, they count
* transitions as states unto themselves (due to network latency and the asynchronous nature
- * of ClientSession's interface). Also, the LOGOUT (and logging out) state has been melded
+ * of ClientSession's interface). Also, the LOGOUT state has been melded
* into {@link ProtocolState.NOT_CONNECTED} on the presumption that the nuances of a disconnected or
* disconnecting session is uninteresting to the caller.
*
@@ -172,14 +172,13 @@ public class Geary.Imap.ClientSession : BaseObject {
NOAUTH,
AUTHORIZED,
SELECTED,
- LOGGED_OUT,
+ LOGOUT,
// transitional states
CONNECTING,
AUTHORIZING,
SELECTING,
CLOSING_MAILBOX,
- LOGGING_OUT,
// terminal state
CLOSED,
@@ -445,29 +444,18 @@ public class Geary.Imap.ClientSession : BaseObject {
new Geary.State.Mapping(State.CLOSING_MAILBOX, Event.SEND_ERROR, on_send_error),
new Geary.State.Mapping(State.CLOSING_MAILBOX, Event.RECV_ERROR, on_recv_error),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.CONNECT, on_already_connected),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.LOGIN, on_already_logged_in),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.SEND_CMD, on_late_command),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.SELECT, on_late_command),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.CLOSE_MAILBOX, on_late_command),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.LOGOUT, Geary.State.nop),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.DISCONNECT, on_disconnect),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.RECV_STATUS, on_logging_out_recv_status),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.RECV_COMPLETION,
on_logging_out_recv_completion),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.RECV_ERROR, on_recv_error),
- new Geary.State.Mapping(State.LOGGING_OUT, Event.SEND_ERROR, on_send_error),
-
- new Geary.State.Mapping(State.LOGGED_OUT, Event.CONNECT, on_already_connected),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.LOGIN, on_already_logged_in),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.SEND_CMD, on_late_command),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.SELECT, on_late_command),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.CLOSE_MAILBOX, on_late_command),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.LOGOUT, on_late_command),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.DISCONNECT, on_disconnect),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.RECV_STATUS, on_dropped_response),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.RECV_COMPLETION, on_dropped_response),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.RECV_ERROR, on_recv_error),
- new Geary.State.Mapping(State.LOGGED_OUT, Event.SEND_ERROR, on_send_error),
+ new Geary.State.Mapping(State.LOGOUT, Event.CONNECT, on_already_connected),
+ new Geary.State.Mapping(State.LOGOUT, Event.LOGIN, on_already_logged_in),
+ new Geary.State.Mapping(State.LOGOUT, Event.SEND_CMD, on_late_command),
+ new Geary.State.Mapping(State.LOGOUT, Event.SELECT, on_late_command),
+ new Geary.State.Mapping(State.LOGOUT, Event.CLOSE_MAILBOX, on_late_command),
+ new Geary.State.Mapping(State.LOGOUT, Event.LOGOUT, on_late_command),
+ new Geary.State.Mapping(State.LOGOUT, Event.DISCONNECT, on_disconnect),
+ new Geary.State.Mapping(State.LOGOUT, Event.DISCONNECTED, on_disconnected),
+ new Geary.State.Mapping(State.LOGOUT, Event.RECV_STATUS, on_logging_out_recv_status),
+ new Geary.State.Mapping(State.LOGOUT, Event.RECV_COMPLETION, on_logging_out_recv_completion),
+ new Geary.State.Mapping(State.LOGOUT, Event.RECV_ERROR, on_recv_error),
+ new Geary.State.Mapping(State.LOGOUT, Event.SEND_ERROR, on_send_error),
new Geary.State.Mapping(State.CLOSED, Event.CONNECT, on_late_command),
new Geary.State.Mapping(State.CLOSED, Event.LOGIN, on_late_command),
@@ -490,7 +478,6 @@ public class Geary.Imap.ClientSession : BaseObject {
~ClientSession() {
switch (fsm.get_state()) {
case State.NOT_CONNECTED:
- case State.LOGGED_OUT:
case State.CLOSED:
// no problem-o
break;
@@ -596,8 +583,7 @@ public class Geary.Imap.ClientSession : BaseObject {
switch (fsm.get_state()) {
case State.NOT_CONNECTED:
- case State.LOGGED_OUT:
- case State.LOGGING_OUT:
+ case State.LOGOUT:
case State.CLOSED:
return ProtocolState.NOT_CONNECTED;
@@ -717,7 +703,7 @@ public class Geary.Imap.ClientSession : BaseObject {
timeout.cancel();
// if session was denied or timeout, ensure the session is disconnected and throw the
- // original Error ... connect_async shouldn't leave the session in a LOGGED_OUT state,
+ // original Error ... connect_async shouldn't leave the session in the CONNECTING state,
// but completely disconnected if unsuccessful
if (connect_err != null) {
try {
@@ -794,7 +780,7 @@ public class Geary.Imap.ClientSession : BaseObject {
imap_endpoint.to_string());
// stay in current state -- wait for initial status response
- // to move into NOAUTH or LOGGED OUT
+ // to move into NOAUTH or LOGOUT
return state;
}
@@ -806,7 +792,7 @@ public class Geary.Imap.ClientSession : BaseObject {
debug("[%s] Disconnected from %s",
to_string(),
this.imap_endpoint.to_string());
- return state;
+ return State.CLOSED;
}
private uint on_connecting_recv_status(uint state, uint event, void *user, Object? object) {
@@ -829,11 +815,14 @@ public class Geary.Imap.ClientSession : BaseObject {
debug("[%s] Connect denied: %s", to_string(), status_response.to_string());
fsm.do_post_transition(() => { session_denied(status_response.get_text()); });
- connect_err = new ImapError.UNAVAILABLE(
+
+ // Don't need to manually disconnect here, by setting
+ // connect_err here that will be done in connect_async
+ this.connect_err = new ImapError.UNAVAILABLE(
"Session denied: %s", status_response.get_text()
);
- return State.LOGGED_OUT;
+ return State.LOGOUT;
}
private uint on_connecting_timeout(uint state, uint event) {
@@ -847,10 +836,14 @@ public class Geary.Imap.ClientSession : BaseObject {
debug("[%s] Connect timed-out", to_string());
- connect_err = new IOError.TIMED_OUT("Session greeting not seen in %u seconds",
- GREETING_TIMEOUT_SEC);
+ // Don't need to manually disconnect here, by setting
+ // connect_err here that will be done in connect_async
+ this.connect_err = new IOError.TIMED_OUT(
+ "Session greeting not seen in %u seconds",
+ GREETING_TIMEOUT_SEC
+ );
- return State.LOGGED_OUT;
+ return State.LOGOUT;
}
/**
@@ -1561,7 +1554,7 @@ public class Geary.Imap.ClientSession : BaseObject {
if (!reserve_state_change_cmd(params, state, event))
return state;
- return State.LOGGING_OUT;
+ return State.LOGOUT;
}
private uint on_logging_out_recv_status(uint state,
@@ -1598,7 +1591,7 @@ public class Geary.Imap.ClientSession : BaseObject {
if (!validate_state_change_cmd(completion_response))
return state;
- return State.LOGGED_OUT;
+ return State.CLOSED;
}
//
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]