From eb6afae35820404c44a350c81cf54f9d2764e8c0 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Sat, 10 Aug 2019 11:46:35 +1000 Subject: [PATCH] Rename UNCONNECTED FSM and protocol state to NOT_CONNECTED The former is ambiguous, the latter is not. --- src/engine/imap/api/imap-client-service.vala | 4 +-- .../imap/transport/imap-client-session.vala | 32 ++++++++++--------- test/integration/imap/client-session.vala | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/engine/imap/api/imap-client-service.vala b/src/engine/imap/api/imap-client-service.vala index f07a2379..6613c44d 100644 --- a/src/engine/imap/api/imap-client-service.vala +++ b/src/engine/imap/api/imap-client-service.vala @@ -1,6 +1,6 @@ /* * Copyright 2016 Software Freedom Conservancy Inc. - * Copyright 2017-2018 Michael Gratton + * Copyright 2017-2019 Michael Gratton * * This software is licensed under the GNU Lesser General Public License * (version 2.1 or later). See the COPYING file in this distribution. @@ -355,7 +355,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService { } break; - case ClientSession.ProtocolState.UNCONNECTED: + case ClientSession.ProtocolState.NOT_CONNECTED: // Already disconnected, so drop it on the floor try { yield remove_session_async(target); diff --git a/src/engine/imap/transport/imap-client-session.vala b/src/engine/imap/transport/imap-client-session.vala index 581da0cc..d3ff645a 100644 --- a/src/engine/imap/transport/imap-client-session.vala +++ b/src/engine/imap/transport/imap-client-session.vala @@ -83,7 +83,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 - * into {@link ProtocolState.UNCONNECTED} on the presumption that the nuances of a disconnected or + * into {@link ProtocolState.NOT_CONNECTED} on the presumption that the nuances of a disconnected or * disconnecting session is uninteresting to the caller. * * See [[http://tools.ietf.org/html/rfc3501#section-3]] @@ -91,7 +91,7 @@ public class Geary.Imap.ClientSession : BaseObject { * @see get_protocol_state */ public enum ProtocolState { - UNCONNECTED, + NOT_CONNECTED, CONNECTING, UNAUTHORIZED, AUTHORIZING, @@ -165,8 +165,10 @@ public class Geary.Imap.ClientSession : BaseObject { } private enum State { + // initial state + NOT_CONNECTED, + // canonical IMAP session states - UNCONNECTED, NOAUTH, AUTHORIZED, SELECTED, @@ -219,7 +221,7 @@ public class Geary.Imap.ClientSession : BaseObject { } private static Geary.State.MachineDescriptor machine_desc = new Geary.State.MachineDescriptor( - "Geary.Imap.ClientSession", State.UNCONNECTED, State.COUNT, Event.COUNT, + "Geary.Imap.ClientSession", State.NOT_CONNECTED, State.COUNT, Event.COUNT, state_to_string, event_to_string); /** @@ -348,13 +350,13 @@ public class Geary.Imap.ClientSession : BaseObject { this.imap_endpoint = imap_endpoint; Geary.State.Mapping[] mappings = { - new Geary.State.Mapping(State.UNCONNECTED, Event.CONNECT, on_connect), - new Geary.State.Mapping(State.UNCONNECTED, Event.LOGIN, on_early_command), - new Geary.State.Mapping(State.UNCONNECTED, Event.SEND_CMD, on_early_command), - new Geary.State.Mapping(State.UNCONNECTED, Event.SELECT, on_early_command), - new Geary.State.Mapping(State.UNCONNECTED, Event.CLOSE_MAILBOX, on_early_command), - new Geary.State.Mapping(State.UNCONNECTED, Event.LOGOUT, on_early_command), - new Geary.State.Mapping(State.UNCONNECTED, Event.DISCONNECT, Geary.State.nop), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.CONNECT, on_connect), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.LOGIN, on_early_command), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.SEND_CMD, on_early_command), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.SELECT, on_early_command), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.CLOSE_MAILBOX, on_early_command), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.LOGOUT, on_early_command), + new Geary.State.Mapping(State.NOT_CONNECTED, Event.DISCONNECT, Geary.State.nop), new Geary.State.Mapping(State.CONNECTING, Event.CONNECT, on_already_connected), new Geary.State.Mapping(State.CONNECTING, Event.LOGIN, on_early_command), @@ -487,7 +489,7 @@ public class Geary.Imap.ClientSession : BaseObject { ~ClientSession() { switch (fsm.get_state()) { - case State.UNCONNECTED: + case State.NOT_CONNECTED: case State.CLOSED: // no problem-o break; @@ -592,11 +594,11 @@ public class Geary.Imap.ClientSession : BaseObject { current_mailbox = null; switch (fsm.get_state()) { - case State.UNCONNECTED: + case State.NOT_CONNECTED: case State.LOGGED_OUT: case State.LOGGING_OUT: case State.CLOSED: - return ProtocolState.UNCONNECTED; + return ProtocolState.NOT_CONNECTED; case State.NOAUTH: return ProtocolState.UNAUTHORIZED; @@ -1197,7 +1199,7 @@ public class Geary.Imap.ClientSession : BaseObject { uint seconds; switch (get_protocol_state(null)) { - case ProtocolState.UNCONNECTED: + case ProtocolState.NOT_CONNECTED: case ProtocolState.CONNECTING: return; diff --git a/test/integration/imap/client-session.vala b/test/integration/imap/client-session.vala index 957cbde6..e2d38a63 100644 --- a/test/integration/imap/client-session.vala +++ b/test/integration/imap/client-session.vala @@ -33,7 +33,7 @@ class Integration.Imap.ClientSession : TestCase { } public override void tear_down() throws GLib.Error { - if (this.session.get_protocol_state(null) != UNCONNECTED) { + if (this.session.get_protocol_state(null) != NOT_CONNECTED) { this.session.disconnect_async.begin(null, async_complete_full); this.session.disconnect_async.end(async_result()); }