Add support for creating/deleting folders to the console app

This commit is contained in:
Michael Gratton 2018-09-26 23:54:47 +10:00
parent 7449e10b3e
commit 6df979dade
3 changed files with 59 additions and 0 deletions

View file

@ -93,6 +93,8 @@ class ImapConsole : Gtk.Window {
"list",
"xlist",
"examine",
"create",
"delete",
"fetch",
"uid-fetch",
"fetch-fields",
@ -184,6 +186,14 @@ class ImapConsole : Gtk.Window {
examine(cmd, args);
break;
case "create":
create(cmd, args);
break;
case "delete":
@delete(cmd, args);
break;
case "fetch":
case "uid-fetch":
fetch(cmd, args);
@ -421,6 +431,28 @@ class ImapConsole : Gtk.Window {
this.cx.send_command(new Geary.Imap.ExamineCommand(new Geary.Imap.MailboxSpecifier(args[0])));
}
private void create(string cmd, string[] args) throws Error {
check_connected(cmd, args, 1, "<mailbox>");
status("Creating %s".printf(args[0]));
this.cx.send_command(
new Geary.Imap.CreateCommand(
new Geary.Imap.MailboxSpecifier(args[0])
)
);
}
private void @delete(string cmd, string[] args) throws Error {
check_connected(cmd, args, 1, "<mailbox>");
status("Deleting %s".printf(args[0]));
this.cx.send_command(
new Geary.Imap.DeleteCommand(
new Geary.Imap.MailboxSpecifier(args[0])
)
);
}
private void fetch(string cmd, string[] args) throws Error {
check_min_connected(cmd, args, 2, "<message-span> <data-item...>");

View file

@ -0,0 +1,26 @@
/*
* Copyright 2018 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
/**
* The RFC 3501 DELETE command.
*
* Deletes the given mailbox. Per the RFC, this must not be used to
* delete mailboxes with child (inferior) mailboxes and that also are
* marked \Noselect.
*
* See [[http://tools.ietf.org/html/rfc3501#section-6.3.4]]
*/
public class Geary.Imap.DeleteCommand : Command {
public const string NAME = "DELETE";
public DeleteCommand(MailboxSpecifier mailbox) {
base(NAME);
this.args.add(mailbox.to_parameter());
}
}

View file

@ -99,6 +99,7 @@ geary_engine_vala_sources = files(
'imap/command/imap-compress-command.vala',
'imap/command/imap-copy-command.vala',
'imap/command/imap-create-command.vala',
'imap/command/imap-delete-command.vala',
'imap/command/imap-examine-command.vala',
'imap/command/imap-expunge-command.vala',
'imap/command/imap-fetch-command.vala',