1 /* 2 * Copyright 2007-2011, 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 <FileConfigView.h> 12 #include <MailAddon.h> 13 #include <MailPrivate.h> 14 #include <ProtocolConfigView.h> 15 16 17 #undef B_TRANSLATION_CONTEXT 18 #define B_TRANSLATION_CONTEXT "ConfigView" 19 20 21 class POP3ConfigView : public BMailProtocolConfigView { 22 public: 23 POP3ConfigView(MailAddonSettings& settings, 24 BMailAccountSettings& accountSettings); 25 status_t Archive(BMessage *into, bool deep = true) const; 26 void GetPreferredSize(float *width, float *height); 27 private: 28 BMailFileConfigView* fFileView; 29 }; 30 31 32 POP3ConfigView::POP3ConfigView(MailAddonSettings& settings, 33 BMailAccountSettings& accountSettings) 34 : 35 BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME 36 | B_MAIL_PROTOCOL_HAS_AUTH_METHODS | B_MAIL_PROTOCOL_HAS_PASSWORD 37 | B_MAIL_PROTOCOL_HAS_HOSTNAME 38 | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER 39 | B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD 40 #if USE_SSL 41 | B_MAIL_PROTOCOL_HAS_FLAVORS 42 #endif 43 ) 44 { 45 AddAuthMethod(B_TRANSLATE("Plain text")); 46 AddAuthMethod(B_TRANSLATE("APOP")); 47 48 #if USE_SSL 49 AddFlavor(B_TRANSLATE("No encryption")); 50 AddFlavor(B_TRANSLATE("SSL")); 51 #endif 52 53 SetTo(settings); 54 55 fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), 56 "destination", false, BPrivate::default_mail_in_directory().Path()); 57 fFileView->SetTo(&settings.Settings(), NULL); 58 AddChild(fFileView); 59 float w, h; 60 BMailProtocolConfigView::GetPreferredSize(&w, &h); 61 fFileView->MoveBy(0, h - 10); 62 GetPreferredSize(&w, &h); 63 ResizeTo(w, h); 64 } 65 66 67 status_t 68 POP3ConfigView::Archive(BMessage *into, bool deep) const 69 { 70 fFileView->Archive(into, deep); 71 return BMailProtocolConfigView::Archive(into, deep); 72 } 73 74 75 void 76 POP3ConfigView::GetPreferredSize(float* width, float* height) 77 { 78 BMailProtocolConfigView::GetPreferredSize(width, height); 79 *height += 20; 80 } 81 82 83 BView* 84 instantiate_config_panel(MailAddonSettings& settings, 85 BMailAccountSettings& accountSettings) 86 { 87 return new POP3ConfigView(settings, accountSettings); 88 } 89 90