2018-08-07 15:01:15 +03:00
|
|
|
/*
|
2020-02-04 15:52:12 +02:00
|
|
|
* meli
|
2018-08-07 15:01:15 +03:00
|
|
|
*
|
|
|
|
* Copyright 2017-2018 Manos Pitsidianakis
|
|
|
|
*
|
|
|
|
* This file is part of meli.
|
|
|
|
*
|
|
|
|
* meli is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* meli is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-08-06 22:20:34 +03:00
|
|
|
/*!
|
|
|
|
* User actions that need to be handled by the UI
|
|
|
|
*/
|
|
|
|
|
2019-06-18 21:13:58 +03:00
|
|
|
use crate::components::Component;
|
2019-09-08 11:05:25 +03:00
|
|
|
pub use melib::thread::{SortField, SortOrder};
|
2018-08-07 11:47:26 +03:00
|
|
|
|
2018-09-04 01:49:29 +03:00
|
|
|
extern crate uuid;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
2019-12-01 17:12:41 +02:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum TagAction {
|
|
|
|
Add(String),
|
|
|
|
Remove(String),
|
|
|
|
}
|
|
|
|
|
2019-03-14 12:19:25 +02:00
|
|
|
#[derive(Debug)]
|
2018-09-04 01:49:29 +03:00
|
|
|
pub enum ListingAction {
|
2018-09-07 09:44:37 +03:00
|
|
|
SetPlain,
|
|
|
|
SetThreaded,
|
|
|
|
SetCompact,
|
2019-09-14 12:43:19 +03:00
|
|
|
SetConversations,
|
2020-02-26 18:36:52 +02:00
|
|
|
Search(String),
|
2020-07-17 00:03:35 +03:00
|
|
|
Select(String),
|
2019-07-18 20:23:02 +03:00
|
|
|
SetSeen,
|
|
|
|
SetUnseen,
|
2020-03-01 17:47:23 +02:00
|
|
|
CopyTo(MailboxPath),
|
2020-06-08 22:08:10 +03:00
|
|
|
CopyToOtherAccount(AccountName, MailboxPath),
|
|
|
|
MoveTo(MailboxPath),
|
|
|
|
MoveToOtherAccount(AccountName, MailboxPath),
|
2019-06-23 11:42:48 +03:00
|
|
|
Delete,
|
2019-09-15 14:10:06 +03:00
|
|
|
OpenInNewTab,
|
2019-12-01 17:12:41 +02:00
|
|
|
Tag(TagAction),
|
2018-08-05 16:26:42 +03:00
|
|
|
}
|
|
|
|
|
2019-03-14 12:19:25 +02:00
|
|
|
#[derive(Debug)]
|
2018-09-04 01:49:29 +03:00
|
|
|
pub enum TabAction {
|
|
|
|
Close,
|
|
|
|
Kill(Uuid),
|
2020-08-25 15:39:43 +03:00
|
|
|
New(Option<Box<dyn Component>>),
|
2018-09-04 01:49:29 +03:00
|
|
|
}
|
|
|
|
|
2019-06-18 22:01:02 +03:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum MailingListAction {
|
|
|
|
ListPost,
|
|
|
|
ListArchive,
|
|
|
|
ListUnsubscribe,
|
|
|
|
}
|
|
|
|
|
2019-07-15 00:04:00 +03:00
|
|
|
#[derive(Debug)]
|
2019-11-10 13:33:22 +02:00
|
|
|
pub enum ViewAction {
|
2019-07-15 00:04:00 +03:00
|
|
|
Pipe(String, Vec<String>),
|
2019-11-10 13:33:22 +02:00
|
|
|
SaveAttachment(usize, String),
|
2019-07-15 00:04:00 +03:00
|
|
|
}
|
|
|
|
|
2019-08-01 12:28:36 +03:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum ComposeAction {
|
|
|
|
AddAttachment(String),
|
2020-03-01 17:45:55 +02:00
|
|
|
AddAttachmentPipe(String),
|
2019-08-01 12:28:36 +03:00
|
|
|
RemoveAttachment(usize),
|
2020-06-23 19:25:01 +03:00
|
|
|
SaveDraft,
|
2019-09-28 10:46:49 +03:00
|
|
|
ToggleSign,
|
2020-10-07 17:16:07 +03:00
|
|
|
ToggleEncrypt,
|
2019-08-01 12:28:36 +03:00
|
|
|
}
|
|
|
|
|
2019-10-30 21:09:48 +02:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum AccountAction {
|
|
|
|
ReIndex,
|
2020-07-25 18:36:01 +03:00
|
|
|
PrintAccountSetting(String),
|
2019-10-30 21:09:48 +02:00
|
|
|
}
|
|
|
|
|
2020-02-06 01:49:18 +02:00
|
|
|
#[derive(Debug)]
|
2020-02-26 10:54:10 +02:00
|
|
|
pub enum MailboxOperation {
|
|
|
|
Create(NewMailboxPath),
|
|
|
|
Delete(MailboxPath),
|
|
|
|
Subscribe(MailboxPath),
|
|
|
|
Unsubscribe(MailboxPath),
|
|
|
|
Rename(MailboxPath, NewMailboxPath),
|
2020-02-06 01:49:18 +02:00
|
|
|
// Placeholder
|
2020-02-26 10:54:10 +02:00
|
|
|
SetPermissions(MailboxPath),
|
2020-02-06 01:49:18 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 12:19:25 +02:00
|
|
|
#[derive(Debug)]
|
2018-08-05 16:26:42 +03:00
|
|
|
pub enum Action {
|
2018-09-04 01:49:29 +03:00
|
|
|
Listing(ListingAction),
|
2018-08-05 16:26:42 +03:00
|
|
|
ViewMailbox(usize),
|
2018-08-07 11:47:26 +03:00
|
|
|
Sort(SortField, SortOrder),
|
|
|
|
SubSort(SortField, SortOrder),
|
2018-09-04 01:49:29 +03:00
|
|
|
Tab(TabAction),
|
2019-05-15 20:58:59 +03:00
|
|
|
ToggleThreadSnooze,
|
2019-06-18 22:01:02 +03:00
|
|
|
MailingListAction(MailingListAction),
|
2019-11-10 13:33:22 +02:00
|
|
|
View(ViewAction),
|
2019-06-26 18:56:29 +03:00
|
|
|
SetEnv(String, String),
|
|
|
|
PrintEnv(String),
|
2019-08-01 12:28:36 +03:00
|
|
|
Compose(ComposeAction),
|
2020-02-26 10:54:10 +02:00
|
|
|
Mailbox(AccountName, MailboxOperation),
|
2019-10-30 21:09:48 +02:00
|
|
|
AccountAction(AccountName, AccountAction),
|
2020-07-25 18:36:01 +03:00
|
|
|
PrintSetting(String),
|
2018-08-05 16:26:42 +03:00
|
|
|
}
|
2019-08-26 19:44:05 +03:00
|
|
|
|
2020-02-19 16:57:37 +02:00
|
|
|
impl Action {
|
|
|
|
pub fn needs_confirmation(&self) -> bool {
|
|
|
|
match self {
|
|
|
|
Action::Listing(_) => false,
|
|
|
|
Action::ViewMailbox(_) => false,
|
|
|
|
Action::Sort(_, _) => false,
|
|
|
|
Action::SubSort(_, _) => false,
|
|
|
|
Action::Tab(_) => false,
|
|
|
|
Action::ToggleThreadSnooze => false,
|
|
|
|
Action::MailingListAction(_) => true,
|
|
|
|
Action::View(_) => false,
|
|
|
|
Action::SetEnv(_, _) => false,
|
|
|
|
Action::PrintEnv(_) => false,
|
|
|
|
Action::Compose(_) => false,
|
2020-02-26 10:54:10 +02:00
|
|
|
Action::Mailbox(_, _) => true,
|
2020-02-19 16:57:37 +02:00
|
|
|
Action::AccountAction(_, _) => false,
|
2020-07-25 18:36:01 +03:00
|
|
|
Action::PrintSetting(_) => false,
|
2020-02-19 16:57:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 19:44:05 +03:00
|
|
|
type AccountName = String;
|
2020-02-26 10:54:10 +02:00
|
|
|
type MailboxPath = String;
|
|
|
|
type NewMailboxPath = String;
|