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> 5 * 6 * Distributed under the terms of the MIT License. 7 */ 8 9 10 #include <Catalog.h> 11 #include <GridLayout.h> 12 #include <MailFilter.h> 13 #include <MenuField.h> 14 #include <TextControl.h> 15 16 #include <FileConfigView.h> 17 #include <MailPrivate.h> 18 #include <ProtocolConfigView.h> 19 20 21 #undef B_TRANSLATION_CONTEXT 22 #define B_TRANSLATION_CONTEXT "ConfigView" 23 24 25 using namespace BPrivate; 26 27 28 class SMTPConfigView : public MailProtocolConfigView { 29 public: 30 SMTPConfigView( 31 const BMailAccountSettings& settings); 32 33 virtual status_t SaveInto(BMailAddOnSettings& settings) const; 34 35 private: 36 MailFileConfigView* fFileView; 37 }; 38 39 40 SMTPConfigView::SMTPConfigView(const BMailAccountSettings& settings) 41 : 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 46 ) 47 { 48 AddFlavor(B_TRANSLATE("Unencrypted")); 49 AddFlavor(B_TRANSLATE("SSL")); 50 51 AddAuthMethod(B_TRANSLATE("None"), false); 52 AddAuthMethod(B_TRANSLATE("ESMTP")); 53 AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false); 54 55 BTextControl* control = (BTextControl*)FindView("host"); 56 control->SetLabel(B_TRANSLATE("SMTP server:")); 57 58 SetTo(settings.OutboundSettings()); 59 60 fFileView = new MailFileConfigView(B_TRANSLATE("Destination:"), "path", 61 false, BPrivate::default_mail_out_directory().Path()); 62 fFileView->SetTo(&settings.OutboundSettings(), NULL); 63 64 Layout()->AddView(fFileView, 0, Layout()->CountRows(), 65 Layout()->CountColumns()); 66 } 67 68 69 status_t 70 SMTPConfigView::SaveInto(BMailAddOnSettings& settings) const 71 { 72 status_t status = fFileView->SaveInto(settings); 73 if (status != B_OK) 74 return status; 75 76 return MailProtocolConfigView::SaveInto(settings); 77 } 78 79 80 // #pragma mark - 81 82 83 BMailSettingsView* 84 instantiate_protocol_settings_view(const BMailAccountSettings& accountSettings, 85 const BMailProtocolSettings& settings) 86 { 87 return new SMTPConfigView(accountSettings); 88 } 89