[geary/wip/actually-imap-logout: 1/5] Handle the expected untagged IMAP BYE status on LOGOUT



commit a932485c96060e59d1dbb212daec6b9d057325fd
Author: Michael Gratton <mike vee net>
Date:   Thu Feb 7 14:00:08 2019 +1100

    Handle the expected untagged IMAP BYE status on LOGOUT

 src/engine/imap/transport/imap-client-session.vala | 39 +++++++++++++++++++---
 1 file changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/imap/transport/imap-client-session.vala 
b/src/engine/imap/transport/imap-client-session.vala
index 8ef5755b..2846c779 100644
--- a/src/engine/imap/transport/imap-client-session.vala
+++ b/src/engine/imap/transport/imap-client-session.vala
@@ -448,7 +448,7 @@ public class Geary.Imap.ClientSession : BaseObject {
             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_dropped_response),
+            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),
@@ -1310,10 +1310,11 @@ public class Geary.Imap.ClientSession : BaseObject {
             case Status.OK:
                 // some good-feeling text that doesn't need to be handled when in this state
             break;
-            
+
             case Status.BYE:
-                debug("[%s] Received BYE from server: %s", to_string(), status_response.to_string());
-                
+                debug("[%s] Received unilateral BYE from server: %s",
+                      to_string(), status_response.to_string());
+
                 // nothing more we can do; drop connection and report disconnect to user
                 cx.disconnect_async.begin(null, on_bye_disconnect_completed);
                 
@@ -1513,7 +1514,35 @@ public class Geary.Imap.ClientSession : BaseObject {
 
         return State.LOGGING_OUT;
     }
-    
+
+    private uint on_logging_out_recv_status(uint state,
+                                            uint event,
+                                            void *user,
+                                            Object? object) {
+        StatusResponse status_response = (StatusResponse) object;
+
+        switch (status_response.status) {
+            case Status.OK:
+                // some good-feeling text that doesn't need to be
+                // handled when in this state
+            break;
+
+            case Status.BYE:
+                // We're expecting this bye, but don't disconnect yet
+                // since we'll do that when the command is complete
+                debug("[%s] Received bye from server on logout: %s",
+                      to_string(), status_response.to_string());
+            break;
+
+            default:
+                debug("[%s] Received error from server on logout: %s",
+                      to_string(), status_response.to_string());
+            break;
+        }
+
+        return state;
+    }
+
     private uint on_logging_out_recv_completion(uint state, uint event, void *user, Object? object) {
         StatusResponse completion_response = (StatusResponse) object;
         


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]