Example #1
0
UINT32 SignatureEditor::OnOk()
{
	// store the HTML source
	BOOL isHTML = m_rich_text_editor->IsHTML();
	OpString signature_content;
	if (isHTML)
		m_rich_text_editor->GetHTMLSource(signature_content,TRUE);
	else
	{
		// the text equivalent returns LF instead of CRLF, we need to convert it
		OpString temp_sig;		
		m_rich_text_editor->GetTextEquivalent(temp_sig);
		UINT32 needed_length = StringConvert::ConvertLineFeedsToLineBreaks(temp_sig.CStr(),temp_sig.Length(),NULL,0);
		uni_char* buf = OP_NEWA(uni_char,needed_length);
		StringConvert::ConvertLineFeedsToLineBreaks(temp_sig.CStr(),temp_sig.Length(),buf,needed_length);
		signature_content.Set(buf,needed_length);
		OP_DELETEA(buf);
	}
	

	// check if we should apply the signature for all accounts or not
	if (GetWidgetValue("apply_for_all_accounts"))
	{
		Account* account = g_m2_engine->GetAccountManager()->GetFirstAccount();

		while (account)
		{
			account->SetSignature(signature_content,isHTML);
			account = (Account*)(account->Suc());
		}

	}
	else
	{
		Account* account = g_m2_engine->GetAccountById(m_account_id);
		if (account)
			account->SetSignature(signature_content, isHTML);
	}
	return 0;
}