🐝 I really like where this mua is(was?) headed, but it seems as though there has not been much activity recently.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.4 KiB

3 years ago
3 years ago
3 years ago
  1. /*
  2. * meli
  3. *
  4. * Copyright 2017-2018 Manos Pitsidianakis
  5. *
  6. * This file is part of meli.
  7. *
  8. * meli is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * meli is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with meli. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /*!
  22. * User actions that need to be handled by the UI
  23. */
  24. use crate::components::Component;
  25. use melib::backends::MailboxHash;
  26. pub use melib::thread::{SortField, SortOrder};
  27. use melib::{Draft, EnvelopeHash};
  28. extern crate uuid;
  29. use uuid::Uuid;
  30. #[derive(Debug)]
  31. pub enum TagAction {
  32. Add(String),
  33. Remove(String),
  34. }
  35. #[derive(Debug)]
  36. pub enum ListingAction {
  37. SetPlain,
  38. SetThreaded,
  39. SetCompact,
  40. SetConversations,
  41. Search(String),
  42. SetSeen,
  43. SetUnseen,
  44. CopyTo(MailboxPath),
  45. Delete,
  46. OpenInNewTab,
  47. Tag(TagAction),
  48. }
  49. #[derive(Debug)]
  50. pub enum TabAction {
  51. New(Option<Box<dyn Component>>),
  52. NewDraft(usize, Option<Draft>),
  53. Reply((usize, MailboxHash), EnvelopeHash), // thread coordinates (account, mailbox) and envelope
  54. Close,
  55. Edit(usize, EnvelopeHash), // account_position, envelope hash
  56. Kill(Uuid),
  57. }
  58. #[derive(Debug)]
  59. pub enum MailingListAction {
  60. ListPost,
  61. ListArchive,
  62. ListUnsubscribe,
  63. }
  64. #[derive(Debug)]
  65. pub enum ViewAction {
  66. Pipe(String, Vec<String>),
  67. SaveAttachment(usize, String),
  68. }
  69. #[derive(Debug)]
  70. pub enum ComposeAction {
  71. AddAttachment(String),
  72. AddAttachmentPipe(String),
  73. RemoveAttachment(usize),
  74. ToggleSign,
  75. }
  76. #[derive(Debug)]
  77. pub enum AccountAction {
  78. ReIndex,
  79. }
  80. #[derive(Debug)]
  81. pub enum MailboxOperation {
  82. Create(NewMailboxPath),
  83. Delete(MailboxPath),
  84. Subscribe(MailboxPath),
  85. Unsubscribe(MailboxPath),
  86. Rename(MailboxPath, NewMailboxPath),
  87. // Placeholder
  88. SetPermissions(MailboxPath),
  89. }
  90. #[derive(Debug)]
  91. pub enum Action {
  92. Listing(ListingAction),
  93. ViewMailbox(usize),
  94. Sort(SortField, SortOrder),
  95. SubSort(SortField, SortOrder),
  96. Tab(TabAction),
  97. ToggleThreadSnooze,
  98. MailingListAction(MailingListAction),
  99. View(ViewAction),
  100. SetEnv(String, String),
  101. PrintEnv(String),
  102. Compose(ComposeAction),
  103. Mailbox(AccountName, MailboxOperation),
  104. AccountAction(AccountName, AccountAction),
  105. }
  106. impl Action {
  107. pub fn needs_confirmation(&self) -> bool {
  108. match self {
  109. Action::Listing(_) => false,
  110. Action::ViewMailbox(_) => false,
  111. Action::Sort(_, _) => false,
  112. Action::SubSort(_, _) => false,
  113. Action::Tab(_) => false,
  114. Action::ToggleThreadSnooze => false,
  115. Action::MailingListAction(_) => true,
  116. Action::View(_) => false,
  117. Action::SetEnv(_, _) => false,
  118. Action::PrintEnv(_) => false,
  119. Action::Compose(_) => false,
  120. Action::Mailbox(_, _) => true,
  121. Action::AccountAction(_, _) => false,
  122. }
  123. }
  124. }
  125. type AccountName = String;
  126. type MailboxPath = String;
  127. type NewMailboxPath = String;