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 #ifdef USE_SSL 46 | B_MAIL_PROTOCOL_HAS_FLAVORS 47 #endif 48 ) 49 { 50 B_TRANSLATE_MARK_VOID("Unencrypted"); 51 B_TRANSLATE_MARK_VOID("SSL"); 52 B_TRANSLATE_MARK_VOID("STARTTLS"); 53 54 #ifdef USE_SSL 55 AddFlavor(B_TRANSLATE_NOCOLLECT("Unencrypted")); 56 AddFlavor(B_TRANSLATE("SSL")); 57 AddFlavor(B_TRANSLATE("STARTTLS")); 58 #endif 59 60 AddAuthMethod(B_TRANSLATE("None"), false); 61 AddAuthMethod(B_TRANSLATE("ESMTP")); 62 AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false); 63 64 BTextControl* control = (BTextControl*)FindView("host"); 65 control->SetLabel(B_TRANSLATE("SMTP server:")); 66 67 SetTo(settings.OutboundSettings()); 68 69 fFileView = new MailFileConfigView(B_TRANSLATE("Destination:"), "path", 70 false, BPrivate::default_mail_out_directory().Path()); 71 fFileView->SetTo(&settings.OutboundSettings(), NULL); 72 73 Layout()->AddView(fFileView, 0, Layout()->CountRows(), 74 Layout()->CountColumns()); 75 } 76 77 78 status_t 79 SMTPConfigView::SaveInto(BMailAddOnSettings& settings) const 80 { 81 status_t status = fFileView->SaveInto(settings); 82 if (status != B_OK) 83 return status; 84 85 return MailProtocolConfigView::SaveInto(settings); 86 } 87 88 89 // #pragma mark - 90 91 92 BMailSettingsView* 93 instantiate_protocol_settings_view(const BMailAccountSettings& accountSettings, 94 const BMailProtocolSettings& settings) 95 { 96 return new SMTPConfigView(accountSettings); 97 } 98