[geary/mjog/imap-connection-fixes: 21/34] Remove Geary.Imap.ClientSession::server-data-received signal



commit 9e01d8dca0c02e05f59adacfaa72e4a2bfe58e7b
Author: Michael Gratton <mike vee net>
Date:   Mon Dec 30 09:55:54 2019 +1030

    Remove Geary.Imap.ClientSession::server-data-received signal
    
    This was only being used internally, and it leaks low level details out
    of the mid-level abstraction.

 src/engine/imap/transport/imap-client-session.vala | 26 +++++++++-------------
 .../imap/transport/imap-client-session-test.vala   | 10 +++++++--
 2 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/engine/imap/transport/imap-client-session.vala 
b/src/engine/imap/transport/imap-client-session.vala
index 3c01a409..32417e5c 100644
--- a/src/engine/imap/transport/imap-client-session.vala
+++ b/src/engine/imap/transport/imap-client-session.vala
@@ -312,12 +312,6 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
     /** Emitted when an IMAP command status response is received. */
     public signal void status_response_received(StatusResponse status_response);
 
-    /**
-     * Fired after the specific {@link ServerData} signals (i.e. {@link capability}, {@link exists}
-     * {@link expunge}, etc.)
-     */
-    public signal void server_data_received(ServerData server_data);
-
     public signal void exists(int count);
 
     public signal void expunge(SequenceNumber seq_num);
@@ -1034,16 +1028,19 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
             yield send_command_async(new CapabilityCommand(), cancellable);
         }
 
-        Gee.List<ServerData> server_data = new Gee.ArrayList<ServerData>();
-        ulong data_id = this.server_data_received.connect((data) => { server_data.add(data); });
+        var list_results = new Gee.ArrayList<MailboxInformation>();
+        ulong list_id = this.list.connect(
+            (mailbox) => { list_results.add(mailbox); }
+        );
         try {
             // Determine what this connection calls the inbox
             Imap.StatusResponse response = yield send_command_async(
                 new ListCommand(MailboxSpecifier.inbox, false, null),
                 cancellable
             );
-            if (response.status == Status.OK && !server_data.is_empty) {
-                this.inbox = server_data[0].get_list();
+            if (response.status == Status.OK && !list_results.is_empty) {
+                this.inbox = list_results[0];
+                list_results.clear();
                 debug("Using INBOX: %s", this.inbox.to_string());
             } else {
                 throw new ImapError.INVALID("Unable to find INBOX");
@@ -1059,7 +1056,6 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
                     warning("NAMESPACE command failed");
                 }
             }
-            server_data.clear();
             if (!this.personal_namespaces.is_empty) {
                 debug(
                     "Default personal namespace: %s",
@@ -1083,8 +1079,8 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
                         new ListCommand(new MailboxSpecifier(prefix), false, null),
                         cancellable
                     );
-                    if (response.status == Status.OK && !server_data.is_empty) {
-                        MailboxInformation list = server_data[0].get_list();
+                    if (response.status == Status.OK && !list_results.is_empty) {
+                        MailboxInformation list = list_results[0];
                         delim = list.delim;
                     } else {
                         throw new ImapError.INVALID("Unable to determine personal namespace delimiter");
@@ -1096,7 +1092,7 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
                       this.personal_namespaces[0].to_string());
             }
         } finally {
-            disconnect(data_id);
+            disconnect(list_id);
         }
     }
 
@@ -1939,8 +1935,6 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
                       server_data.to_string());
             break;
         }
-
-        server_data_received(server_data);
     }
 
     private void clear_namespaces() {
diff --git a/test/engine/imap/transport/imap-client-session-test.vala 
b/test/engine/imap/transport/imap-client-session-test.vala
index b3243c8f..8ba46c8a 100644
--- a/test/engine/imap/transport/imap-client-session-test.vala
+++ b/test/engine/imap/transport/imap-client-session-test.vala
@@ -256,7 +256,7 @@ class Geary.Imap.ClientSessionTest : TestCase {
         this.server.add_script_line(SEND_LINE, "* CAPABILITY IMAP4rev1");
         this.server.add_script_line(SEND_LINE, "a003 OK thanks");
         this.server.add_script_line(RECEIVE_LINE, "a004 LIST \"\" INBOX");
-        this.server.add_script_line(SEND_LINE, "* LIST (\\HasChildren) \".\" INBOX");
+        this.server.add_script_line(SEND_LINE, "* LIST (\\HasChildren) \".\" Inbox");
         this.server.add_script_line(SEND_LINE, "a004 OK there");
         this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
 
@@ -280,6 +280,9 @@ class Geary.Imap.ClientSessionTest : TestCase {
         assert_false(test_article.capabilities.has_capability("AUTH"));
         assert_int(2, test_article.capabilities.revision);
 
+        assert_string("Inbox", test_article.inbox.mailbox.name);
+        assert_true(test_article.inbox.mailbox.is_inbox);
+
         test_article.disconnect_async.begin(null, this.async_complete_full);
         test_article.disconnect_async.end(async_result());
 
@@ -297,7 +300,7 @@ class Geary.Imap.ClientSessionTest : TestCase {
         this.server.add_script_line(RECEIVE_LINE, "a001 login test password");
         this.server.add_script_line(SEND_LINE, "a001 OK [CAPABILITY IMAP4rev1] ohhai");
         this.server.add_script_line(RECEIVE_LINE, "a002 LIST \"\" INBOX");
-        this.server.add_script_line(SEND_LINE, "* LIST (\\HasChildren) \".\" INBOX");
+        this.server.add_script_line(SEND_LINE, "* LIST (\\HasChildren) \".\" Inbox");
         this.server.add_script_line(SEND_LINE, "a002 OK there");
         this.server.add_script_line(WAIT_FOR_DISCONNECT, "");
 
@@ -321,6 +324,9 @@ class Geary.Imap.ClientSessionTest : TestCase {
         assert_false(test_article.capabilities.has_capability("AUTH"));
         assert_int(2, test_article.capabilities.revision);
 
+        assert_string("Inbox", test_article.inbox.mailbox.name);
+        assert_true(test_article.inbox.mailbox.is_inbox);
+
         test_article.disconnect_async.begin(null, this.async_complete_full);
         test_article.disconnect_async.end(async_result());
 


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