vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / mail_daemon / outbound_protocols / smtp / ConfigView.cpp
blobfee7454b06842de28bc89b355fb7b83f7fef34a9
1 /*
2 * Copyright 2007-2012, Haiku, Inc. All rights reserved.
3 * Copyright 2001-2002, Dr. Zoidberg Enterprises. All rights reserved.
4 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
6 * Distributed under the terms of the MIT License.
7 */
10 #include <Catalog.h>
11 #include <GridLayout.h>
12 #include <MailFilter.h>
13 #include <MenuField.h>
14 #include <TextControl.h>
16 #include <FileConfigView.h>
17 #include <MailPrivate.h>
18 #include <ProtocolConfigView.h>
21 #undef B_TRANSLATION_CONTEXT
22 #define B_TRANSLATION_CONTEXT "ConfigView"
25 using namespace BPrivate;
28 class SMTPConfigView : public MailProtocolConfigView {
29 public:
30 SMTPConfigView(
31 const BMailAccountSettings& settings);
33 virtual status_t SaveInto(BMailAddOnSettings& settings) const;
35 private:
36 MailFileConfigView* fFileView;
40 SMTPConfigView::SMTPConfigView(const BMailAccountSettings& settings)
42 MailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS
43 | B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD
44 | B_MAIL_PROTOCOL_HAS_HOSTNAME
45 | B_MAIL_PROTOCOL_HAS_FLAVORS
48 AddFlavor(B_TRANSLATE("Unencrypted"));
49 AddFlavor(B_TRANSLATE("SSL"));
51 AddAuthMethod(B_TRANSLATE("None"), false);
52 AddAuthMethod(B_TRANSLATE("ESMTP"));
53 AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);
55 BTextControl* control = (BTextControl*)FindView("host");
56 control->SetLabel(B_TRANSLATE("SMTP server:"));
58 SetTo(settings.OutboundSettings());
60 fFileView = new MailFileConfigView(B_TRANSLATE("Destination:"), "path",
61 false, BPrivate::default_mail_out_directory().Path());
62 fFileView->SetTo(&settings.OutboundSettings(), NULL);
64 Layout()->AddView(fFileView, 0, Layout()->CountRows(),
65 Layout()->CountColumns());
69 status_t
70 SMTPConfigView::SaveInto(BMailAddOnSettings& settings) const
72 status_t status = fFileView->SaveInto(settings);
73 if (status != B_OK)
74 return status;
76 return MailProtocolConfigView::SaveInto(settings);
80 // #pragma mark -
83 BMailSettingsView*
84 instantiate_protocol_settings_view(const BMailAccountSettings& accountSettings,
85 const BMailProtocolSettings& settings)
87 return new SMTPConfigView(accountSettings);