xref: /haiku/src/add-ons/mail_daemon/inbound_protocols/pop3/ConfigView.cpp (revision 2cad94c1c30b6223ad8c08710b26e071d32e9979)
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 #if USE_SSL
46 		| B_MAIL_PROTOCOL_HAS_FLAVORS
47 #endif
48 		)
49 {
50 	AddAuthMethod(B_TRANSLATE("Plain text"));
51 	AddAuthMethod(B_TRANSLATE("APOP"));
52 
53 #if USE_SSL
54 	AddFlavor(B_TRANSLATE("No encryption"));
55 	AddFlavor(B_TRANSLATE("SSL"));
56 #endif
57 
58 	SetTo(settings);
59 
60 	fFileView = new MailFileConfigView(B_TRANSLATE("Destination:"),
61 		"destination", false, BPrivate::default_mail_in_directory().Path());
62 	fFileView->SetTo(&settings, NULL);
63 
64 	Layout()->AddView(fFileView, 0, Layout()->CountRows(),
65 		Layout()->CountColumns());
66 }
67 
68 
69 status_t
70 POP3ConfigView::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 POP3ConfigView(settings);
88 }
89