Beispiel #1
0
void
MailProtocol::LoadFilters(MailAddonSettings& settings)
{
    for (int i = 0; i < settings.CountFilterSettings(); i++) {
        AddonSettings* filterSettings = settings.FilterSettingsAt(i);
        MailFilter* filter = _LoadFilter(filterSettings);
        if (!filter)
            continue;
        AddFilter(filter);
    }
}
Beispiel #2
0
void
BMailProtocolConfigView::SetTo(MailAddonSettings& settings)
{
 	const BMessage* archive = &settings.Settings();

	BString host = archive->FindString("server");
	if (archive->HasInt32("port"))
		host << ':' << archive->FindInt32("port");

	SetTextControl(this,"host", host.String());
	SetTextControl(this,"user", archive->FindString("username"));

	char *password = get_passwd(archive, "cpasswd");
	if (password) {
		SetTextControl(this,"pass", password);
		delete[] password;
	} else
		SetTextControl(this,"pass", archive->FindString("password"));

	if (archive->HasInt32("flavor")) {
		BMenuField *menu = (BMenuField *)(FindView("flavor"));
		if (menu != NULL) {
			if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("flavor")))
				item->SetMarked(true);
		}
	}

	if (archive->HasInt32("auth_method")) {
		BMenuField *menu = (BMenuField *)(FindView("auth_method"));
		if (menu != NULL) {
			if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("auth_method"))) {
				item->SetMarked(true);
				if (item->Command() != 'none') {
					enable_control("user");
					enable_control("pass");
				}
			}
		}
	}


	BCheckBox *box = (BCheckBox *)(FindView("leave_mail_on_server"));
	if (box != NULL)
		box->SetValue(archive->FindBool("leave_mail_on_server") ? B_CONTROL_ON : B_CONTROL_OFF);

	box = (BCheckBox *)(FindView("delete_remote_when_local"));
	if (box != NULL) {
		box->SetValue(archive->FindBool("delete_remote_when_local") ? B_CONTROL_ON : B_CONTROL_OFF);

		if (archive->FindBool("leave_mail_on_server"))
			box->SetEnabled(true);
		else
			box->SetEnabled(false);
	}

	if (fBodyDownloadConfig)
		fBodyDownloadConfig->SetTo(settings);
}
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);
}
Beispiel #4
0
void
BodyDownloadConfig::SetTo(MailAddonSettings& addonSettings)
{
	const BMessage* settings = &addonSettings.Settings();

	int32 limit = 0;
	if (settings->HasInt32(kPartialDownloadLimit))
		limit = settings->FindInt32(kPartialDownloadLimit);
	if (limit < 0) {
		fPartialBox->SetValue(B_CONTROL_OFF);
		fSizeBox->SetText("0");
		fSizeBox->SetEnabled(false);
	} else {
		limit = int32(limit / 1024);
		BString kb;
		kb << limit;
		fSizeBox->SetText(kb);
		fPartialBox->SetValue(B_CONTROL_ON);
		fSizeBox->SetEnabled(true);
	}
}