SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
	BMailAccountSettings& accountSettings)
	:
	BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS
		| B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD
		| B_MAIL_PROTOCOL_HAS_HOSTNAME
#ifdef USE_SSL
		| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
		)
{
#if defined(USE_SSL) || defined(B_COLLECTING_CATKEYS)
	static const char* kUnencryptedStr = B_TRANSLATE_MARK("Unencrypted");
	static const char* kSSLStr = B_TRANSLATE_MARK("SSL");
	static const char* kSTARTTLSStr = B_TRANSLATE_MARK("STARTTLS");
#endif

#ifdef USE_SSL
	AddFlavor(B_TRANSLATE_NOCOLLECT(kUnencryptedStr));
	AddFlavor(B_TRANSLATE(kSSLStr));
	AddFlavor(B_TRANSLATE(kSTARTTLSStr));
#endif

	AddAuthMethod(B_TRANSLATE("None"), false);
	AddAuthMethod(B_TRANSLATE("ESMTP"));
	AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);

	BTextControl *control = (BTextControl *)(FindView("host"));
	control->SetLabel(B_TRANSLATE("SMTP server:"));

	// Reset the dividers after changing one
	float widestLabel = 0;
	for (int32 i = CountChildren(); i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			widestLabel = MAX(widestLabel,text->StringWidth(text->Label()) + 5);
	}
	for (int32 i = CountChildren(); i-- > 0;) {
		if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
			text->SetDivider(widestLabel);
	}

	BMenuField *field = (BMenuField *)(FindView("auth_method"));
	field->SetDivider(widestLabel);

	SetTo(settings);

	fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path",
		false, BPrivate::default_mail_out_directory().Path());
	fFileView->SetTo(&settings.Settings(), NULL);
	AddChild(fFileView);
	float w, h;
	BMailProtocolConfigView::GetPreferredSize(&w, &h);
	fFileView->MoveBy(0, h - 10);
	GetPreferredSize(&w, &h);
	ResizeTo(w, h);
}
Esempio n. 2
0
IMAPConfig::IMAPConfig(BMessage *archive)
	: BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME
		| B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME
		| B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER
#ifdef USE_SSL
	 	| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
	 )
{
#ifdef USE_SSL
		AddFlavor("No encryption");
		AddFlavor("SSL");
#endif

	SetTo(archive);

	((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON);
	((BControl *)(FindView("leave_mail_remote")))->Hide();

	BRect frame = FindView("delete_remote_when_local")->Frame();

	((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true);
	((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25);


	frame.right -= 10;// FindView("pass")->Frame().right;
	/*frame.top += 10;
	frame.bottom += 10;*/

	BTextControl *folder = new BTextControl(frame,"root","Top mailbox folder: ","",NULL);
	folder->SetDivider(be_plain_font->StringWidth("Top mailbox folder: "));

	if (archive->HasString("root"))
		folder->SetText(archive->FindString("root"));

	AddChild(folder);

	ResizeToPreferred();
}