Rename UNCONNECTED FSM and protocol state to NOT_CONNECTED

The former is ambiguous, the latter is not.
This commit is contained in:
Michael Gratton 2019-08-10 11:46:35 +10:00
parent 63210247dd
commit eb6afae358
3 changed files with 20 additions and 18 deletions

View file

@ -1,6 +1,6 @@
/* /*
* Copyright 2016 Software Freedom Conservancy Inc. * Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2017-2018 Michael Gratton <mike@vee.net> * Copyright 2017-2019 Michael Gratton <mike@vee.net>
* *
* This software is licensed under the GNU Lesser General Public License * This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
@ -355,7 +355,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
} }
break; break;
case ClientSession.ProtocolState.UNCONNECTED: case ClientSession.ProtocolState.NOT_CONNECTED:
// Already disconnected, so drop it on the floor // Already disconnected, so drop it on the floor
try { try {
yield remove_session_async(target); yield remove_session_async(target);

View file

@ -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 * 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 * 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 (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. * disconnecting session is uninteresting to the caller.
* *
* See [[http://tools.ietf.org/html/rfc3501#section-3]] * See [[http://tools.ietf.org/html/rfc3501#section-3]]
@ -91,7 +91,7 @@ public class Geary.Imap.ClientSession : BaseObject {
* @see get_protocol_state * @see get_protocol_state
*/ */
public enum ProtocolState { public enum ProtocolState {
UNCONNECTED, NOT_CONNECTED,
CONNECTING, CONNECTING,
UNAUTHORIZED, UNAUTHORIZED,
AUTHORIZING, AUTHORIZING,
@ -165,8 +165,10 @@ public class Geary.Imap.ClientSession : BaseObject {
} }
private enum State { private enum State {
// initial state
NOT_CONNECTED,
// canonical IMAP session states // canonical IMAP session states
UNCONNECTED,
NOAUTH, NOAUTH,
AUTHORIZED, AUTHORIZED,
SELECTED, SELECTED,
@ -219,7 +221,7 @@ public class Geary.Imap.ClientSession : BaseObject {
} }
private static Geary.State.MachineDescriptor machine_desc = new Geary.State.MachineDescriptor( 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); state_to_string, event_to_string);
/** /**
@ -348,13 +350,13 @@ public class Geary.Imap.ClientSession : BaseObject {
this.imap_endpoint = imap_endpoint; this.imap_endpoint = imap_endpoint;
Geary.State.Mapping[] mappings = { Geary.State.Mapping[] mappings = {
new Geary.State.Mapping(State.UNCONNECTED, Event.CONNECT, on_connect), new Geary.State.Mapping(State.NOT_CONNECTED, Event.CONNECT, on_connect),
new Geary.State.Mapping(State.UNCONNECTED, Event.LOGIN, on_early_command), new Geary.State.Mapping(State.NOT_CONNECTED, Event.LOGIN, on_early_command),
new Geary.State.Mapping(State.UNCONNECTED, Event.SEND_CMD, on_early_command), new Geary.State.Mapping(State.NOT_CONNECTED, Event.SEND_CMD, on_early_command),
new Geary.State.Mapping(State.UNCONNECTED, Event.SELECT, on_early_command), new Geary.State.Mapping(State.NOT_CONNECTED, Event.SELECT, on_early_command),
new Geary.State.Mapping(State.UNCONNECTED, Event.CLOSE_MAILBOX, on_early_command), new Geary.State.Mapping(State.NOT_CONNECTED, Event.CLOSE_MAILBOX, on_early_command),
new Geary.State.Mapping(State.UNCONNECTED, Event.LOGOUT, on_early_command), new Geary.State.Mapping(State.NOT_CONNECTED, Event.LOGOUT, on_early_command),
new Geary.State.Mapping(State.UNCONNECTED, Event.DISCONNECT, Geary.State.nop), 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.CONNECT, on_already_connected),
new Geary.State.Mapping(State.CONNECTING, Event.LOGIN, on_early_command), new Geary.State.Mapping(State.CONNECTING, Event.LOGIN, on_early_command),
@ -487,7 +489,7 @@ public class Geary.Imap.ClientSession : BaseObject {
~ClientSession() { ~ClientSession() {
switch (fsm.get_state()) { switch (fsm.get_state()) {
case State.UNCONNECTED: case State.NOT_CONNECTED:
case State.CLOSED: case State.CLOSED:
// no problem-o // no problem-o
break; break;
@ -592,11 +594,11 @@ public class Geary.Imap.ClientSession : BaseObject {
current_mailbox = null; current_mailbox = null;
switch (fsm.get_state()) { switch (fsm.get_state()) {
case State.UNCONNECTED: case State.NOT_CONNECTED:
case State.LOGGED_OUT: case State.LOGGED_OUT:
case State.LOGGING_OUT: case State.LOGGING_OUT:
case State.CLOSED: case State.CLOSED:
return ProtocolState.UNCONNECTED; return ProtocolState.NOT_CONNECTED;
case State.NOAUTH: case State.NOAUTH:
return ProtocolState.UNAUTHORIZED; return ProtocolState.UNAUTHORIZED;
@ -1197,7 +1199,7 @@ public class Geary.Imap.ClientSession : BaseObject {
uint seconds; uint seconds;
switch (get_protocol_state(null)) { switch (get_protocol_state(null)) {
case ProtocolState.UNCONNECTED: case ProtocolState.NOT_CONNECTED:
case ProtocolState.CONNECTING: case ProtocolState.CONNECTING:
return; return;

View file

@ -33,7 +33,7 @@ class Integration.Imap.ClientSession : TestCase {
} }
public override void tear_down() throws GLib.Error { 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.begin(null, async_complete_full);
this.session.disconnect_async.end(async_result()); this.session.disconnect_async.end(async_result());
} }