Exemple #1
0
OP_STATUS OPMLM2ImportHandler::OnOutlineBegin(const OpStringC& text,
	const OpStringC& xml_url, const OpStringC& title,
	const OpStringC& description)
{
	if (xml_url.HasContent())
	{
		const OpStringC& folder_name = title.HasContent() ? title : text;

		// First we see if this index already exists.
		Index* index = m_indexer->GetSubscribedFolderIndex(m_newsfeed_account, xml_url, 0, folder_name, FALSE, FALSE);
		if (index == 0)
		{
			// Didn't exist; create it.
			if ((index = m_indexer->GetSubscribedFolderIndex(m_newsfeed_account, xml_url, 0, folder_name, TRUE, FALSE)) == 0)
				return OpStatus::ERR;

			g_m2_engine->RefreshFolder(index->GetId());

			if (m_parent_folder)
				index->SetParentId(m_parent_folder->GetId());

			++m_import_count;
		}
	}
	else
	{
		// this is a folder
		m_parent_folder = m_indexer->GetFeedFolderIndexByName(m_parent_folder->GetId(), title.HasContent() ? title : text);
	}

	return OpStatus::OK;
}
void AccessTreeViewListener::OnItemEdited(OpWidget *widget, INT32 pos, INT32 column, OpString& text)
{
	INT32 id = m_treeview.GetItemByPosition(pos)->GetID();
	Index* index = g_m2_engine->GetIndexById(id);
	index->SetName(text.CStr());
	g_m2_engine->UpdateIndex(index->GetId());
}
Exemple #3
0
IndexGroupRange::IndexGroupRange(index_gid_t index_id, index_gid_t range_start, index_gid_t range_end)
	: UnionIndexGroup(index_id)
	, m_or_range_start(range_start)
	, m_or_range_end(range_end)
{
	// Or all indexes currently in the range
	INT32 it = -1;
	Index* index;
	while ((index = m_indexer->GetRange(range_start, range_end, it)) != NULL)
	{
		AddIndex(index->GetId());
	}
}
Exemple #4
0
IndexGroupMailingLists::IndexGroupMailingLists(index_gid_t index_id)
	: UnionIndexGroup(index_id)
{
	// Check all indexes that might be mailing lists
	INT32 it = -1;
	Index* index = m_indexer->GetRange(IndexTypes::FIRST_CONTACT, IndexTypes::LAST_CONTACT, it);

	while (index)
	{
		IndexSearch *search = index->GetSearch();
		if (search && search->GetSearchText().FindFirstOf('@') == KNotFound &&
			search->GetSearchText().FindFirstOf('.') != KNotFound)
		{
			AddIndex(index->GetId());
		}
		index = m_indexer->GetRange(IndexTypes::FIRST_CONTACT, IndexTypes::LAST_CONTACT, it);
	}
}
Exemple #5
0
IndexGroupWatched::IndexGroupWatched(index_gid_t index_id, index_gid_t range_start, index_gid_t range_end)
	: UnionIndexGroup(index_id)
	, m_or_range_start(range_start)
	, m_or_range_end(range_end)
{
	// Or all indexes currently in the range that are being watched
	INT32 it = -1;
	Index* index = m_indexer->GetRange(range_start, range_end, it);

	while (index)
	{
		if (index->IsWatched())
		{
			AddIndex(index->GetId());
		}
		index = m_indexer->GetRange(range_start, range_end, it);
	}
}
Exemple #6
0
/***********************************************************************************
 **
 ** MailRecovery::GhostBuster
 ***********************************************************************************/
OP_STATUS MailRecovery::GhostBuster()
{
    Store* store = g_m2_engine->GetStore();
    // we can only run this if we have loaded all messages!
    if (!store->HasFinishedLoading())
        return OpStatus::OK;

    OpString8 indexes_with_ghosts;
    OpStringC8 log_heading("Ghostbuster");
    OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,"Started"));
    INT32 num_ghosts = 0;
    Index* current;
    // go through all indexes
    for (INT32 it = -1; (current = g_m2_engine->GetIndexer()->GetRange(0, IndexTypes::LAST, it)) != NULL; )
    {
        OpINT32Vector message_ids;

        if (OpStatus::IsError(current->PreFetch()) || OpStatus::IsError(current->GetAllMessages(message_ids)))
            continue;

        // go through all messages in all indexes
        for (UINT32 nb = 0; nb < message_ids.GetCount(); nb++)
        {
            INT32 message_id = message_ids.Get(nb);
            // check if the message really exists in store
            if (!store->MessageAvailable(message_id))
            {
                // we have a ghost, a message that doesn't exist in store, but exists in an index
                current->RemoveMessage(message_id);
                num_ghosts++;
                indexes_with_ghosts.AppendFormat(" %d",current->GetId());
            }
        }
    }
    OpStatus::Ignore(store->CommitData());
    OpString8 log_text;
    OpStatus::Ignore(log_text.AppendFormat("Finished: Deleted %d ghosts from the following indexes:%s", num_ghosts, indexes_with_ghosts.CStr()));
    OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,log_text));
    return OpStatus::OK;
}
Exemple #7
0
void GroupsModel::Commit()
{
	if (m_read_only)
		return;

	Account* account = MessageEngine::GetInstance()->GetAccountById(m_account_id);

	BOOL account_changed = FALSE;

	if (account)
	{
		account->StopFolderLoading();

		UINT32 index_to_show = 0;

		for (int pos = 0; pos < GetItemCount(); pos++)
		{
			GroupsModelItem* item = GetItemByIndex(pos);
			if (item)
			{
				OpString path, name;
				OpStatus::Ignore(item->GetPath(path));
				OpStatus::Ignore(item->GetName(name));

				if (item->PathIsChanged() && !item->IsManuallyAdded())
				{
					OpString old_path;
					OpStatus::Ignore(item->GetOldPath(old_path));
					OpStatus::Ignore(account->RenameFolder(old_path, path));
				}

				if (item->SubscriptionIsChanged())
				{
					if (item->IsManuallyAdded())
					{
						OpStatus::Ignore(account->CreateFolder(path, item->GetIsSubscribed()));
					}

					if (item->GetIsSubscribed())
					{
						OpStatus::Ignore(account->AddSubscribedFolder(path));
                        account->SetIsTemporary(FALSE);
						if (m_folder_type != OpTypedObject::IMAPFOLDER_TYPE)
						{
							Index* index = MessageEngine::GetInstance()->GetIndexer()->GetSubscribedFolderIndex(account, path, 0, name, TRUE, FALSE);
							if (index)
							{
								MessageEngine::GetInstance()->RefreshFolder(index->GetId());
								if (index_to_show)
									index_to_show = IndexTypes::FIRST_ACCOUNT + m_account_id;
								else
									index_to_show = index->GetId();
							}
						}
					}
					else
					{
						Index* index = MessageEngine::GetInstance()->GetIndexer()->GetSubscribedFolderIndex(account, path, 0, name, FALSE, FALSE);

						if (index)
							OpStatus::Ignore(account->RemoveSubscribedFolder(index->GetId()));
						else
							OpStatus::Ignore(account->RemoveSubscribedFolder(path));
					}
					account_changed = TRUE;
				}
				else if (item->GetIsSubscribed() && m_folder_type != OpTypedObject::IMAPFOLDER_TYPE)
				{
					MessageEngine::GetInstance()->GetIndexer()->GetSubscribedFolderIndex(account, path, 0, name, TRUE, FALSE);
				}
			}
		}
		if (account_changed)
		{
			account->CommitSubscribedFolders();
		}

		if (index_to_show)
		{
			g_application->GoToMailView(index_to_show, NULL, NULL, TRUE, FALSE, TRUE);
		}
	}
}
Exemple #8
0
UINT32 GroupsModelItem::GetIndexId()
{
	Index* index = MessageEngine::GetInstance()->GetIndexer()->GetSubscribedFolderIndex(MessageEngine::GetInstance()->GetAccountById(m_account_id), m_path, 0, m_name, FALSE, FALSE);
	return index ? index->GetId() : 0;
}
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());
					}
				}
			}