From 1f71f02a9da569b485c1903612dbf7bb88b91dfb Mon Sep 17 00:00:00 2001 From: Jim Nelson Date: Wed, 5 Jun 2013 15:02:12 -0700 Subject: [PATCH] Broke out Commands into separate files with barebone Valadocs. --- src/CMakeLists.txt | 21 +- .../imap/command/imap-capability-command.vala | 20 ++ .../imap/command/imap-close-command.vala | 18 ++ src/engine/imap/command/imap-commands.vala | 201 ------------------ .../imap/command/imap-compress-command.vala | 20 ++ .../imap/command/imap-copy-command.vala | 22 ++ .../imap/command/imap-examine-command.vala | 22 ++ .../imap/command/imap-expunge-command.vala | 28 +++ src/engine/imap/command/imap-id-command.vala | 32 +++ .../imap/command/imap-idle-command.vala | 20 ++ .../imap/command/imap-list-command.vala | 29 +++ .../imap/command/imap-login-command.vala | 22 ++ .../imap/command/imap-logout-command.vala | 18 ++ .../imap/command/imap-noop-command.vala | 20 ++ .../imap/command/imap-select-command.vala | 22 ++ .../imap/command/imap-starttls-command.vala | 18 ++ .../imap/command/imap-status-command.vala | 29 +++ .../imap/command/imap-store-command.vala | 32 +++ 18 files changed, 390 insertions(+), 204 deletions(-) create mode 100644 src/engine/imap/command/imap-capability-command.vala create mode 100644 src/engine/imap/command/imap-close-command.vala delete mode 100644 src/engine/imap/command/imap-commands.vala create mode 100644 src/engine/imap/command/imap-compress-command.vala create mode 100644 src/engine/imap/command/imap-copy-command.vala create mode 100644 src/engine/imap/command/imap-examine-command.vala create mode 100644 src/engine/imap/command/imap-expunge-command.vala create mode 100644 src/engine/imap/command/imap-id-command.vala create mode 100644 src/engine/imap/command/imap-idle-command.vala create mode 100644 src/engine/imap/command/imap-list-command.vala create mode 100644 src/engine/imap/command/imap-login-command.vala create mode 100644 src/engine/imap/command/imap-logout-command.vala create mode 100644 src/engine/imap/command/imap-noop-command.vala create mode 100644 src/engine/imap/command/imap-select-command.vala create mode 100644 src/engine/imap/command/imap-starttls-command.vala create mode 100644 src/engine/imap/command/imap-status-command.vala create mode 100644 src/engine/imap/command/imap-store-command.vala diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78bfede8..58514d78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,18 +62,33 @@ engine/db/db-transaction-outcome.vala engine/db/db-transaction-type.vala engine/db/db-versioned-database.vala +engine/imap/imap.vala +engine/imap/imap-error.vala engine/imap/api/imap-account.vala engine/imap/api/imap-email-flags.vala engine/imap/api/imap-email-identifier.vala engine/imap/api/imap-email-properties.vala engine/imap/api/imap-folder-properties.vala engine/imap/api/imap-folder.vala -engine/imap/command/imap-commands.vala +engine/imap/command/imap-capability-command.vala +engine/imap/command/imap-close-command.vala engine/imap/command/imap-command.vala +engine/imap/command/imap-compress-command.vala +engine/imap/command/imap-copy-command.vala +engine/imap/command/imap-examine-command.vala +engine/imap/command/imap-expunge-command.vala engine/imap/command/imap-fetch-command.vala +engine/imap/command/imap-id-command.vala +engine/imap/command/imap-idle-command.vala +engine/imap/command/imap-list-command.vala +engine/imap/command/imap-login-command.vala +engine/imap/command/imap-logout-command.vala engine/imap/command/imap-message-set.vala -engine/imap/imap.vala -engine/imap/imap-error.vala +engine/imap/command/imap-noop-command.vala +engine/imap/command/imap-select-command.vala +engine/imap/command/imap-starttls-command.vala +engine/imap/command/imap-status-command.vala +engine/imap/command/imap-store-command.vala engine/imap/message/imap-data-format.vala engine/imap/message/imap-fetch-body-data-type.vala engine/imap/message/imap-fetch-data-type.vala diff --git a/src/engine/imap/command/imap-capability-command.vala b/src/engine/imap/command/imap-capability-command.vala new file mode 100644 index 00000000..448eb676 --- /dev/null +++ b/src/engine/imap/command/imap-capability-command.vala @@ -0,0 +1,20 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.1.1]] + * + * @see Capabilities + */ + +public class Geary.Imap.CapabilityCommand : Command { + public const string NAME = "capability"; + + public CapabilityCommand() { + base (NAME); + } +} + diff --git a/src/engine/imap/command/imap-close-command.vala b/src/engine/imap/command/imap-close-command.vala new file mode 100644 index 00000000..a61a4d73 --- /dev/null +++ b/src/engine/imap/command/imap-close-command.vala @@ -0,0 +1,18 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.4.2]] + */ + +public class Geary.Imap.CloseCommand : Command { + public const string NAME = "close"; + + public CloseCommand() { + base (NAME); + } +} + diff --git a/src/engine/imap/command/imap-commands.vala b/src/engine/imap/command/imap-commands.vala deleted file mode 100644 index a4e6a750..00000000 --- a/src/engine/imap/command/imap-commands.vala +++ /dev/null @@ -1,201 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -public class Geary.Imap.CapabilityCommand : Command { - public const string NAME = "capability"; - - public CapabilityCommand() { - base (NAME); - } -} - -public class Geary.Imap.CompressCommand : Command { - public const string NAME = "compress"; - - public const string ALGORITHM_DEFLATE = "deflate"; - - public CompressCommand(string algorithm) { - base (NAME, { algorithm }); - } -} - -public class Geary.Imap.StarttlsCommand : Command { - public const string NAME = "starttls"; - - public StarttlsCommand() { - base (NAME); - } -} - -public class Geary.Imap.NoopCommand : Command { - public const string NAME = "noop"; - - public NoopCommand() { - base (NAME); - } -} - -public class Geary.Imap.LoginCommand : Command { - public const string NAME = "login"; - - public LoginCommand(string user, string pass) { - base (NAME, { user, pass }); - } - - public override string to_string() { - return "%s %s ".printf(tag.to_string(), name); - } -} - -public class Geary.Imap.LogoutCommand : Command { - public const string NAME = "logout"; - - public LogoutCommand() { - base (NAME); - } -} - -public class Geary.Imap.ListCommand : Command { - public const string NAME = "list"; - public const string XLIST_NAME = "xlist"; - - public ListCommand(MailboxSpecifier mailbox, bool use_xlist) { - base (use_xlist ? XLIST_NAME : NAME, { "" }); - - add(mailbox.to_parameter()); - } - - public ListCommand.wildcarded(string reference, MailboxSpecifier mailbox, bool use_xlist) { - base (use_xlist ? XLIST_NAME : NAME, { reference }); - - add(mailbox.to_parameter()); - } -} - -public class Geary.Imap.ExamineCommand : Command { - public const string NAME = "examine"; - - public ExamineCommand(MailboxSpecifier mailbox) { - base (NAME); - - add(mailbox.to_parameter()); - } -} - -public class Geary.Imap.SelectCommand : Command { - public const string NAME = "select"; - - public SelectCommand(MailboxSpecifier mailbox) { - base (NAME); - - add(mailbox.to_parameter()); - } -} - -public class Geary.Imap.CloseCommand : Command { - public const string NAME = "close"; - - public CloseCommand() { - base (NAME); - } -} - -public class Geary.Imap.StatusCommand : Command { - public const string NAME = "status"; - - public StatusCommand(MailboxSpecifier mailbox, StatusDataType[] data_items) { - base (NAME); - - add(mailbox.to_parameter()); - - assert(data_items.length > 0); - ListParameter data_item_list = new ListParameter(this); - foreach (StatusDataType data_item in data_items) - data_item_list.add(data_item.to_parameter()); - - add(data_item_list); - } -} - -public class Geary.Imap.StoreCommand : Command { - public const string NAME = "store"; - public const string UID_NAME = "uid store"; - - public StoreCommand(MessageSet message_set, Gee.List flag_list, bool add_flag, - bool silent) { - base (message_set.is_uid ? UID_NAME : NAME); - - add(message_set.to_parameter()); - add(new StringParameter("%sflags%s".printf(add_flag ? "+" : "-", silent ? ".silent" : ""))); - - ListParameter list = new ListParameter(this); - foreach(MessageFlag flag in flag_list) - list.add(new StringParameter(flag.value)); - - add(list); - } -} - -// Results of this command automatically handled by Geary.Imap.UnsolicitedServerData -public class Geary.Imap.ExpungeCommand : Command { - public const string NAME = "expunge"; - public const string UID_NAME = "uid expunge"; - - public ExpungeCommand() { - base (NAME); - } - - public ExpungeCommand.uid(MessageSet message_set) { - base (UID_NAME); - - assert(message_set.is_uid); - - add(message_set.to_parameter()); - } -} - -public class Geary.Imap.IdleCommand : Command { - public const string NAME = "idle"; - - public IdleCommand() { - base (NAME); - } -} - -public class Geary.Imap.CopyCommand : Command { - public const string NAME = "copy"; - public const string UID_NAME = "uid copy"; - - public CopyCommand(MessageSet message_set, MailboxSpecifier destination) { - base (message_set.is_uid ? UID_NAME : NAME); - - add(message_set.to_parameter()); - add(destination.to_parameter()); - } -} - -public class Geary.Imap.IdCommand : Command { - public const string NAME = "id"; - - public IdCommand(Gee.HashMap fields) { - base (NAME); - - ListParameter list = new ListParameter(this); - foreach (string key in fields.keys) { - list.add(new QuotedStringParameter(key)); - list.add(new QuotedStringParameter(fields.get(key))); - } - - add(list); - } - - public IdCommand.nil() { - base (NAME); - - add(NilParameter.instance); - } -} - diff --git a/src/engine/imap/command/imap-compress-command.vala b/src/engine/imap/command/imap-compress-command.vala new file mode 100644 index 00000000..f2dfb87d --- /dev/null +++ b/src/engine/imap/command/imap-compress-command.vala @@ -0,0 +1,20 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc4978]] + */ + +public class Geary.Imap.CompressCommand : Command { + public const string NAME = "compress"; + + public const string ALGORITHM_DEFLATE = "deflate"; + + public CompressCommand(string algorithm) { + base (NAME, { algorithm }); + } +} + diff --git a/src/engine/imap/command/imap-copy-command.vala b/src/engine/imap/command/imap-copy-command.vala new file mode 100644 index 00000000..3c842a3d --- /dev/null +++ b/src/engine/imap/command/imap-copy-command.vala @@ -0,0 +1,22 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.4.7]] + */ + +public class Geary.Imap.CopyCommand : Command { + public const string NAME = "copy"; + public const string UID_NAME = "uid copy"; + + public CopyCommand(MessageSet message_set, MailboxSpecifier destination) { + base (message_set.is_uid ? UID_NAME : NAME); + + add(message_set.to_parameter()); + add(destination.to_parameter()); + } +} + diff --git a/src/engine/imap/command/imap-examine-command.vala b/src/engine/imap/command/imap-examine-command.vala new file mode 100644 index 00000000..8d758b73 --- /dev/null +++ b/src/engine/imap/command/imap-examine-command.vala @@ -0,0 +1,22 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.3.2]] + * + * @see SelectCommand + */ + +public class Geary.Imap.ExamineCommand : Command { + public const string NAME = "examine"; + + public ExamineCommand(MailboxSpecifier mailbox) { + base (NAME); + + add(mailbox.to_parameter()); + } +} + diff --git a/src/engine/imap/command/imap-expunge-command.vala b/src/engine/imap/command/imap-expunge-command.vala new file mode 100644 index 00000000..250c7c19 --- /dev/null +++ b/src/engine/imap/command/imap-expunge-command.vala @@ -0,0 +1,28 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.4.3]] and + * [[http://tools.ietf.org/html/rfc4315#section-2.1]] + */ + +public class Geary.Imap.ExpungeCommand : Command { + public const string NAME = "expunge"; + public const string UID_NAME = "uid expunge"; + + public ExpungeCommand() { + base (NAME); + } + + public ExpungeCommand.uid(MessageSet message_set) { + base (UID_NAME); + + assert(message_set.is_uid); + + add(message_set.to_parameter()); + } +} + diff --git a/src/engine/imap/command/imap-id-command.vala b/src/engine/imap/command/imap-id-command.vala new file mode 100644 index 00000000..ec693243 --- /dev/null +++ b/src/engine/imap/command/imap-id-command.vala @@ -0,0 +1,32 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://www.ietf.org/rfc/rfc2971.txt]] + */ + +public class Geary.Imap.IdCommand : Command { + public const string NAME = "id"; + + public IdCommand(Gee.HashMap fields) { + base (NAME); + + ListParameter list = new ListParameter(this); + foreach (string key in fields.keys) { + list.add(new QuotedStringParameter(key)); + list.add(new QuotedStringParameter(fields.get(key))); + } + + add(list); + } + + public IdCommand.nil() { + base (NAME); + + add(NilParameter.instance); + } +} + diff --git a/src/engine/imap/command/imap-idle-command.vala b/src/engine/imap/command/imap-idle-command.vala new file mode 100644 index 00000000..caa2e3e7 --- /dev/null +++ b/src/engine/imap/command/imap-idle-command.vala @@ -0,0 +1,20 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc2177]] + * + * @see NoopCommand + */ + +public class Geary.Imap.IdleCommand : Command { + public const string NAME = "idle"; + + public IdleCommand() { + base (NAME); + } +} + diff --git a/src/engine/imap/command/imap-list-command.vala b/src/engine/imap/command/imap-list-command.vala new file mode 100644 index 00000000..6392c505 --- /dev/null +++ b/src/engine/imap/command/imap-list-command.vala @@ -0,0 +1,29 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.3.8]] + * + * @see MailboxInformation + */ + +public class Geary.Imap.ListCommand : Command { + public const string NAME = "list"; + public const string XLIST_NAME = "xlist"; + + public ListCommand(MailboxSpecifier mailbox, bool use_xlist) { + base (use_xlist ? XLIST_NAME : NAME, { "" }); + + add(mailbox.to_parameter()); + } + + public ListCommand.wildcarded(string reference, MailboxSpecifier mailbox, bool use_xlist) { + base (use_xlist ? XLIST_NAME : NAME, { reference }); + + add(mailbox.to_parameter()); + } +} + diff --git a/src/engine/imap/command/imap-login-command.vala b/src/engine/imap/command/imap-login-command.vala new file mode 100644 index 00000000..303df553 --- /dev/null +++ b/src/engine/imap/command/imap-login-command.vala @@ -0,0 +1,22 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.2.3]] + */ + +public class Geary.Imap.LoginCommand : Command { + public const string NAME = "login"; + + public LoginCommand(string user, string pass) { + base (NAME, { user, pass }); + } + + public override string to_string() { + return "%s %s ".printf(tag.to_string(), name); + } +} + diff --git a/src/engine/imap/command/imap-logout-command.vala b/src/engine/imap/command/imap-logout-command.vala new file mode 100644 index 00000000..d58b9571 --- /dev/null +++ b/src/engine/imap/command/imap-logout-command.vala @@ -0,0 +1,18 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.1.3]] + */ + +public class Geary.Imap.LogoutCommand : Command { + public const string NAME = "logout"; + + public LogoutCommand() { + base (NAME); + } +} + diff --git a/src/engine/imap/command/imap-noop-command.vala b/src/engine/imap/command/imap-noop-command.vala new file mode 100644 index 00000000..03c8b556 --- /dev/null +++ b/src/engine/imap/command/imap-noop-command.vala @@ -0,0 +1,20 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.1.2]] + * + * @see IdleCommand + */ + +public class Geary.Imap.NoopCommand : Command { + public const string NAME = "noop"; + + public NoopCommand() { + base (NAME); + } +} + diff --git a/src/engine/imap/command/imap-select-command.vala b/src/engine/imap/command/imap-select-command.vala new file mode 100644 index 00000000..0e58052d --- /dev/null +++ b/src/engine/imap/command/imap-select-command.vala @@ -0,0 +1,22 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.3.1]] + * + * @see ExamineCommand + */ + +public class Geary.Imap.SelectCommand : Command { + public const string NAME = "select"; + + public SelectCommand(MailboxSpecifier mailbox) { + base (NAME); + + add(mailbox.to_parameter()); + } +} + diff --git a/src/engine/imap/command/imap-starttls-command.vala b/src/engine/imap/command/imap-starttls-command.vala new file mode 100644 index 00000000..9d4f2b86 --- /dev/null +++ b/src/engine/imap/command/imap-starttls-command.vala @@ -0,0 +1,18 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.2.1]] + */ + +public class Geary.Imap.StarttlsCommand : Command { + public const string NAME = "starttls"; + + public StarttlsCommand() { + base (NAME); + } +} + diff --git a/src/engine/imap/command/imap-status-command.vala b/src/engine/imap/command/imap-status-command.vala new file mode 100644 index 00000000..62d8332a --- /dev/null +++ b/src/engine/imap/command/imap-status-command.vala @@ -0,0 +1,29 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.3.10]] + * + * @see StatusData + */ + +public class Geary.Imap.StatusCommand : Command { + public const string NAME = "status"; + + public StatusCommand(MailboxSpecifier mailbox, StatusDataType[] data_items) { + base (NAME); + + add(mailbox.to_parameter()); + + assert(data_items.length > 0); + ListParameter data_item_list = new ListParameter(this); + foreach (StatusDataType data_item in data_items) + data_item_list.add(data_item.to_parameter()); + + add(data_item_list); + } +} + diff --git a/src/engine/imap/command/imap-store-command.vala b/src/engine/imap/command/imap-store-command.vala new file mode 100644 index 00000000..d9d32961 --- /dev/null +++ b/src/engine/imap/command/imap-store-command.vala @@ -0,0 +1,32 @@ +/* Copyright 2011-2013 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * See [[http://tools.ietf.org/html/rfc3501#section-6.4.6]] + * + * @see FetchCommand + * @see FetchedData + */ + +public class Geary.Imap.StoreCommand : Command { + public const string NAME = "store"; + public const string UID_NAME = "uid store"; + + public StoreCommand(MessageSet message_set, Gee.List flag_list, bool add_flag, + bool silent) { + base (message_set.is_uid ? UID_NAME : NAME); + + add(message_set.to_parameter()); + add(new StringParameter("%sflags%s".printf(add_flag ? "+" : "-", silent ? ".silent" : ""))); + + ListParameter list = new ListParameter(this); + foreach(MessageFlag flag in flag_list) + list.add(new StringParameter(flag.value)); + + add(list); + } +} +