BOOL MailPanel::OnInputAction(OpInputAction* action) { index_gid_t id = action->GetActionData(); switch (action->GetAction()) { case OpInputAction::ACTION_GET_ACTION_STATE: { OpInputAction* child_action = action->GetChildAction(); id = child_action->GetActionData(); switch (child_action->GetAction()) { case OpInputAction::ACTION_MAIL_SHOW_INDEX: { BOOL enabled = FALSE; if ((IndexTypes::FIRST_CATEGORY <= id && id <= IndexTypes::LAST_CATEGORY) || (IndexTypes::FIRST_ACCOUNT <= id && id <= IndexTypes::LAST_ACCOUNT)) { if (!(id >= IndexTypes::FIRST_ACCOUNT && id < IndexTypes::LAST_ACCOUNT && !g_m2_engine->GetAccountManager()->IsAccountActive((UINT16)id-IndexTypes::FIRST_ACCOUNT))) enabled = child_action->GetActionDataString() || !g_m2_engine->GetIndexer()->GetCategoryVisible(id); } else { enabled = child_action->GetActionDataString() || !g_m2_engine->GetIndexer()->GetIndexById(id)->IsVisible(); } child_action->SetEnabled(enabled); return TRUE; } case OpInputAction::ACTION_MAIL_HIDE_INDEX: { if (!child_action->GetActionDataString()) { BOOL visible, enabled = TRUE; if ((IndexTypes::FIRST_CATEGORY <= id && id <= IndexTypes::LAST_CATEGORY) || (IndexTypes::FIRST_ACCOUNT <= id && id <= IndexTypes::LAST_ACCOUNT)) { visible = g_m2_engine->GetIndexer()->GetCategoryVisible(id); if ((id >= IndexTypes::FIRST_ACCOUNT && id < IndexTypes::LAST_ACCOUNT) && (!g_m2_engine->GetAccountManager()->IsAccountActive((UINT16)id-IndexTypes::FIRST_ACCOUNT) || (g_application->HasFeeds() && !g_application->HasMail()))) { enabled = FALSE; } } else { visible = g_m2_engine->GetIndexer()->GetIndexById(id)->IsVisible(); } child_action->SetSelected(visible && child_action->GetActionOperator() != OpInputAction::OPERATOR_NONE); child_action->SetEnabled(visible && enabled); } else { if (g_m2_engine->GetIndexer()->GetSubscribedFolderIndex(g_m2_engine->GetAccountById(id), child_action->GetActionDataString(), 0, NULL, FALSE, FALSE)) { child_action->SetSelected(TRUE); child_action->SetEnabled(TRUE); } else { child_action->SetEnabled(FALSE); } } return TRUE; } case OpInputAction::ACTION_NEW_FOLDER: { child_action->SetEnabled(TRUE); return TRUE; } case OpInputAction::ACTION_RELOAD: { child_action->SetEnabled(g_m2_engine->GetAccountManager()->GetRSSAccount(FALSE) != NULL); return TRUE; } case OpInputAction::ACTION_EDIT_PROPERTIES: { child_action->SetEnabled(g_m2_engine->GetIndexer()->IsCategory(child_action->GetActionData())); return TRUE; } case OpInputAction::ACTION_RENAME: case OpInputAction::ACTION_EXPORT_MAIL_INDEX: case OpInputAction::ACTION_DELETE: case OpInputAction::ACTION_MARK_ALL_AS_READ: { child_action->SetEnabled(FALSE); return TRUE; } } break; } case OpInputAction::ACTION_MAIL_SHOW_INDEX: { if (action->GetActionDataString()) g_m2_engine->GetIndexer()->GetSubscribedFolderIndex(g_m2_engine->GetAccountById(id), action->GetActionDataString(), 0, action->GetActionText(), TRUE, FALSE); else { if ((IndexTypes::FIRST_CATEGORY <= id && id <= IndexTypes::LAST_CATEGORY) || (IndexTypes::FIRST_ACCOUNT <= id && id <= IndexTypes::LAST_ACCOUNT)) { g_m2_engine->GetIndexer()->SetCategoryVisible(id, TRUE); } else { g_m2_engine->GetIndexer()->GetIndexById(id)->SetVisible(TRUE); } } return TRUE; } case OpInputAction::ACTION_MAIL_HIDE_INDEX: { if (g_input_manager->GetActionState(action,this) & OpInputAction::STATE_ENABLED) { if (action->GetActionDataString()) { Index* index = g_m2_engine->GetIndexer()->GetSubscribedFolderIndex(g_m2_engine->GetAccountById(id), action->GetActionDataString(), 0, action->GetActionText(), FALSE, FALSE); if (index) OpStatus::Ignore(g_m2_engine->GetAccountById(id)->RemoveSubscribedFolder(index->GetId())); } else { if ((IndexTypes::FIRST_CATEGORY <= id && id <= IndexTypes::LAST_CATEGORY) || (IndexTypes::FIRST_ACCOUNT <= id && id <= IndexTypes::LAST_ACCOUNT)) { g_m2_engine->GetIndexer()->SetCategoryVisible(id, FALSE); } else { g_m2_engine->GetIndexer()->GetIndexById(id)->SetVisible(FALSE); } } return TRUE; } break; } case OpInputAction::ACTION_NEW_NEWSFEED: { OpAccordion::OpAccordionItem * accordion_item = m_accordion->GetItemById(action->GetActionData()); if (accordion_item) { m_accordion->ExpandItem(accordion_item, TRUE); accordion_item->GetWidget()->OnInputAction(action); } return TRUE; } case OpInputAction::ACTION_NEW_FOLDER: { index_gid_t parent_id = 0; if (action->GetActionData()) { parent_id = action->GetActionData(); } else if (g_application->HasMail()) // clicking new folder outside an accordion item when you have a mail account should default back to new label { parent_id = IndexTypes::CATEGORY_LABELS; } else if (g_application->HasFeeds()) // but when there is no mail account, it should make a new feed folder { parent_id = g_m2_engine->GetAccountManager()->GetRSSAccount(FALSE)->GetAccountId() + IndexTypes::FIRST_ACCOUNT; } if (!parent_id) return TRUE; OpAccordion::OpAccordionItem * accordion_item = m_accordion->GetItemById(parent_id); if (!accordion_item) // the section is hidden... the action can still be performed in any accesstreeview, but won't make it appear accordion_item = m_accordion->GetItemByIndex(0); if (accordion_item) { m_accordion->ExpandItem(accordion_item, TRUE); static_cast<AccessTreeView*>(accordion_item->GetWidget())->CreateNewFolder(parent_id); } return TRUE; } case OpInputAction::ACTION_EDIT_PROPERTIES: { index_gid_t id = action->GetActionData(); // Edit Properties for filters if (id == IndexTypes::CATEGORY_LABELS ) { LabelPropertiesController* controller = OP_NEW(LabelPropertiesController, (id)); ShowDialog(controller, g_global_ui_context, GetParentDesktopWindow()); } // Edit Properties for accounts (imap, rss, pop, etc) else if (id >= IndexTypes::FIRST_ACCOUNT && id < IndexTypes::LAST_ACCOUNT) { Account* account = g_m2_engine->GetAccountById(id-IndexTypes::FIRST_ACCOUNT); if (account) { if (account->GetIncomingIndexType() == IndexTypes::NEWSFEED_INDEX) { AccountSubscriptionDialog* dialog = OP_NEW(AccountSubscriptionDialog, ()); if (dialog) dialog->Init(AccountTypes::RSS, GetParentDesktopWindow()); } else { AccountPropertiesDialog* dialog = OP_NEW(AccountPropertiesDialog, (FALSE)); if (dialog) dialog->Init(account->GetAccountId(),GetParentDesktopWindow()); } } }