Adapted POP3, and Fortune to the new MailSettingsView API.
This commit is contained in:
parent
1da1e5a166
commit
006040d06e
@ -25,15 +25,17 @@ using namespace BPrivate;
|
||||
|
||||
class POP3ConfigView : public MailProtocolConfigView {
|
||||
public:
|
||||
POP3ConfigView(BMailAccountSettings& settings);
|
||||
status_t Archive(BMessage* into, bool deep = true) const;
|
||||
POP3ConfigView(
|
||||
const BMailProtocolSettings& settings);
|
||||
|
||||
virtual status_t SaveInto(BMailAddOnSettings& settings) const;
|
||||
|
||||
private:
|
||||
MailFileConfigView* fFileView;
|
||||
};
|
||||
|
||||
|
||||
POP3ConfigView::POP3ConfigView(BMailAccountSettings& settings)
|
||||
POP3ConfigView::POP3ConfigView(const BMailProtocolSettings& settings)
|
||||
:
|
||||
MailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME
|
||||
| B_MAIL_PROTOCOL_HAS_AUTH_METHODS | B_MAIL_PROTOCOL_HAS_PASSWORD
|
||||
@ -53,11 +55,11 @@ POP3ConfigView::POP3ConfigView(BMailAccountSettings& settings)
|
||||
AddFlavor(B_TRANSLATE("SSL"));
|
||||
#endif
|
||||
|
||||
SetTo(settings.InboundSettings());
|
||||
SetTo(settings);
|
||||
|
||||
fFileView = new MailFileConfigView(B_TRANSLATE("Destination:"),
|
||||
"destination", false, BPrivate::default_mail_in_directory().Path());
|
||||
fFileView->SetTo(&settings.InboundSettings(), NULL);
|
||||
fFileView->SetTo(&settings, NULL);
|
||||
|
||||
Layout()->AddView(fFileView, 0, Layout()->CountRows(),
|
||||
Layout()->CountColumns());
|
||||
@ -65,18 +67,22 @@ POP3ConfigView::POP3ConfigView(BMailAccountSettings& settings)
|
||||
|
||||
|
||||
status_t
|
||||
POP3ConfigView::Archive(BMessage* into, bool deep) const
|
||||
POP3ConfigView::SaveInto(BMailAddOnSettings& settings) const
|
||||
{
|
||||
fFileView->Archive(into, deep);
|
||||
return MailProtocolConfigView::Archive(into, deep);
|
||||
status_t status = fFileView->SaveInto(settings);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return MailProtocolConfigView::SaveInto(settings);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
BView*
|
||||
instantiate_protocol_config_panel(BMailAccountSettings& settings)
|
||||
BMailSettingsView*
|
||||
instantiate_protocol_settings_view(const BMailAccountSettings& accountSettings,
|
||||
const BMailProtocolSettings& settings)
|
||||
{
|
||||
return new POP3ConfigView(settings);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ using namespace BPrivate;
|
||||
|
||||
ConfigView::ConfigView()
|
||||
:
|
||||
BView("fortune_filter", 0)
|
||||
BMailSettingsView("fortune_filter")
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
@ -40,13 +40,12 @@ ConfigView::ConfigView()
|
||||
|
||||
|
||||
void
|
||||
ConfigView::SetTo(const BMessage* archive)
|
||||
ConfigView::SetTo(const BMailAddOnSettings& settings)
|
||||
{
|
||||
fFileView->SetTo(archive, NULL);
|
||||
fFileView->SetTo(&settings, NULL);
|
||||
|
||||
BString path = archive->FindString("tag_line");
|
||||
if (!archive->HasString("tag_line"))
|
||||
path = B_TRANSLATE("Fortune cookie says:\n\n");
|
||||
BString path = settings.GetString("tag_line",
|
||||
B_TRANSLATE("Fortune cookie says:\n\n"));
|
||||
|
||||
path.Truncate(path.Length() - 2);
|
||||
fTagControl->SetText(path.String());
|
||||
@ -54,15 +53,12 @@ ConfigView::SetTo(const BMessage* archive)
|
||||
|
||||
|
||||
status_t
|
||||
ConfigView::Archive(BMessage* into, bool /*deep*/) const
|
||||
ConfigView::SaveInto(BMailAddOnSettings& settings) const
|
||||
{
|
||||
fFileView->Archive(into);
|
||||
fFileView->SaveInto(settings);
|
||||
|
||||
BString line = fTagControl->Text();
|
||||
if (line != B_EMPTY_STRING)
|
||||
line << "\n\n";
|
||||
if (into->ReplaceString("tag_line", line.String()) != B_OK)
|
||||
into->AddString("tag_line", line.String());
|
||||
|
||||
return B_OK;
|
||||
return settings.SetString("tag_line", line.String());
|
||||
}
|
||||
|
@ -8,15 +8,18 @@
|
||||
#define CONFIG_VIEW_H
|
||||
|
||||
|
||||
#include <MailSettingsView.h>
|
||||
|
||||
#include <FileConfigView.h>
|
||||
|
||||
|
||||
class ConfigView : public BView {
|
||||
class ConfigView : public BMailSettingsView {
|
||||
public:
|
||||
ConfigView();
|
||||
void SetTo(const BMessage* archive);
|
||||
|
||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||
void SetTo(const BMailAddOnSettings& settings);
|
||||
|
||||
virtual status_t SaveInto(BMailAddOnSettings& settings) const;
|
||||
|
||||
private:
|
||||
BPrivate::MailFileConfigView* fFileView;
|
||||
|
@ -30,9 +30,7 @@
|
||||
class FortuneFilter : public BMailFilter {
|
||||
public:
|
||||
FortuneFilter(BMailProtocol& protocol,
|
||||
BMailAddOnSettings* settings);
|
||||
|
||||
virtual BString DescriptiveName() const;
|
||||
const BMailAddOnSettings& settings);
|
||||
|
||||
virtual void MessageReadyToSend(const entry_ref& ref,
|
||||
BFile* file);
|
||||
@ -40,18 +38,10 @@ public:
|
||||
|
||||
|
||||
FortuneFilter::FortuneFilter(BMailProtocol& protocol,
|
||||
BMailAddOnSettings* settings)
|
||||
const BMailAddOnSettings& settings)
|
||||
:
|
||||
BMailFilter(protocol, settings)
|
||||
BMailFilter(protocol, &settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
FortuneFilter::DescriptiveName() const
|
||||
{
|
||||
return filter_name();
|
||||
}
|
||||
|
||||
|
||||
@ -106,24 +96,27 @@ FortuneFilter::MessageReadyToSend(const entry_ref& ref, BFile* file)
|
||||
|
||||
|
||||
BString
|
||||
filter_name()
|
||||
filter_name(const BMailAccountSettings& accountSettings,
|
||||
const BMailAddOnSettings* settings)
|
||||
{
|
||||
return B_TRANSLATE("Fortune");
|
||||
}
|
||||
|
||||
|
||||
BMailFilter*
|
||||
instantiate_filter(BMailProtocol& protocol, BMailAddOnSettings* settings)
|
||||
instantiate_filter(BMailProtocol& protocol,
|
||||
const BMailAddOnSettings& settings)
|
||||
{
|
||||
return new FortuneFilter(protocol, settings);
|
||||
}
|
||||
|
||||
|
||||
BView*
|
||||
instantiate_filter_config_panel(BMailAddOnSettings& settings)
|
||||
BMailSettingsView*
|
||||
instantiate_filter_settings_view(const BMailAccountSettings& accountSettings,
|
||||
const BMailAddOnSettings& settings)
|
||||
{
|
||||
ConfigView* view = new ConfigView();
|
||||
view->SetTo(&settings);
|
||||
view->SetTo(settings);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user