From 452937dea52c2f37d480509989421eeca1aaeac0 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Fri, 19 Jun 2020 16:05:41 +0200 Subject: [PATCH] Changed command `listFolder` to `listMail` --- README.md | 2 +- source/client/client.d | 24 ++++++++++++++++++++++-- source/client/mail.d | 5 +++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ef2398c..569556e 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ JSON sent: ```json { - "command" : "listFolder", + "command" : "listMail", "request" : { "folderName" : "" } diff --git a/source/client/client.d b/source/client/client.d index ae6070a..5d1a9c4 100644 --- a/source/client/client.d +++ b/source/client/client.d @@ -8,6 +8,7 @@ import std.json; import std.string; import client.mail; import server.server; +import std.conv : to; public final class ButterflyClient : Thread { @@ -255,18 +256,37 @@ public final class ButterflyClient : Thread /* TODO: Add error handling */ } } - else if(cmp(command, "listFolder") == 0) + else if(cmp(command, "listMail") == 0) { /* Make sure the connection is from a client */ if(connectionType == ClientType.CLIENT) { - /* TODO: Implement me */ + /* Get the folder wanting to be listed */ + Folder listFolder = new Folder(mailbox, commandBlock["request"]["folderName"].str()); + + responseBlock["mailIDs"] = to!(string)(listFolder.getMessages()); } else { /* TODO: Add error handling */ } } + else if(cmp(command, "listFolder") == 0) + { + /* Make sure the connection is from a client */ + if(connectionType == ClientType.CLIENT) + { + /* Get the folder wanting to be listed */ + Folder listFolder = new Folder(mailbox, commandBlock["request"]["folderName"].str()); + + //responseBlock["folders"] = to!(string)(listFolder.getMessages()); + } + else + { + /* TODO: Add error handling */ + } + } + else if(cmp(command, "totsiens") == 0) { /* Close the connection on next loop condition check */ diff --git a/source/client/mail.d b/source/client/mail.d index b0dd420..64c0217 100644 --- a/source/client/mail.d +++ b/source/client/mail.d @@ -335,4 +335,9 @@ public final class Mail return messageBlock; } + + override public string toString() + { + return "\""~mailID~"\""; + } } \ No newline at end of file