xref: /haiku/src/add-ons/mail_daemon/inbound_protocols/pop3/ConfigView.cpp (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
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 
14 #include <FileConfigView.h>
15 #include <MailPrivate.h>
16 #include <ProtocolConfigView.h>
17 
18 
19 #undef B_TRANSLATION_CONTEXT
20 #define B_TRANSLATION_CONTEXT "ConfigView"
21 
22 
23 using namespace BPrivate;
24 
25 
26 class POP3ConfigView : public MailProtocolConfigView {
27 public:
28 								POP3ConfigView(
29 									const BMailProtocolSettings& settings);
30 
31 	virtual status_t			SaveInto(BMailAddOnSettings& settings) const;
32 
33 private:
34 			MailFileConfigView*	fFileView;
35 };
36 
37 
38 POP3ConfigView::POP3ConfigView(const BMailProtocolSettings& settings)
39 	:
40 	MailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME
41 		| B_MAIL_PROTOCOL_HAS_AUTH_METHODS | B_MAIL_PROTOCOL_HAS_PASSWORD
42 		| B_MAIL_PROTOCOL_HAS_HOSTNAME
43 		| B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER
44 		| B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD
45 		| B_MAIL_PROTOCOL_HAS_FLAVORS
46 		)
47 {
48 	AddAuthMethod(B_TRANSLATE("Plain text"));
49 	AddAuthMethod(B_TRANSLATE("APOP"));
50 
51 	AddFlavor(B_TRANSLATE("No encryption"));
52 	AddFlavor(B_TRANSLATE("SSL"));
53 
54 	SetTo(settings);
55 
56 	fFileView = new MailFileConfigView(B_TRANSLATE("Destination:"),
57 		"destination", false, BPrivate::default_mail_in_directory().Path());
58 	fFileView->SetTo(&settings, NULL);
59 
60 	Layout()->AddView(fFileView, 0, Layout()->CountRows(),
61 		Layout()->CountColumns());
62 }
63 
64 
65 status_t
66 POP3ConfigView::SaveInto(BMailAddOnSettings& settings) const
67 {
68 	status_t status = fFileView->SaveInto(settings);
69 	if (status != B_OK)
70 		return status;
71 
72 	return MailProtocolConfigView::SaveInto(settings);
73 }
74 
75 
76 // #pragma mark -
77 
78 
79 BMailSettingsView*
80 instantiate_protocol_settings_view(const BMailAccountSettings& accountSettings,
81 	const BMailProtocolSettings& settings)
82 {
83 	return new POP3ConfigView(settings);
84 }
85