2 * Copyright 2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, <axeld@pinc-software.de>
11 #include <NetworkSettings.h>
12 #include <NetworkSettingsAddOn.h>
14 #include "ServiceListItem.h"
15 #include "ServiceView.h"
18 using namespace BNetworkKit
;
21 #undef B_TRANSLATION_CONTEXT
22 #define B_TRANSLATION_CONTEXT "FTPServiceAddOn"
25 class FTPServiceAddOn
: public BNetworkSettingsAddOn
{
27 FTPServiceAddOn(image_id image
,
28 BNetworkSettings
& settings
);
29 virtual ~FTPServiceAddOn();
31 virtual BNetworkSettingsItem
*
32 CreateNextItem(uint32
& cookie
);
36 class FTPServiceItem
: public BNetworkSettingsItem
{
38 FTPServiceItem(BNetworkSettings
& settings
);
39 virtual ~FTPServiceItem();
41 virtual BNetworkSettingsType
44 virtual BListItem
* ListItem();
45 virtual BView
* View();
47 virtual status_t
Revert();
48 virtual bool IsRevertable();
50 virtual void SettingsUpdated(uint32 which
);
53 BNetworkSettings
& fSettings
;
62 FTPServiceItem::FTPServiceItem(BNetworkSettings
& settings
)
65 fItem(new ServiceListItem("ftp", B_TRANSLATE("FTP server"), settings
)),
71 FTPServiceItem::~FTPServiceItem()
73 if (fView
->Parent() == NULL
)
81 FTPServiceItem::Type() const
83 return B_NETWORK_SETTINGS_TYPE_SERVICE
;
88 FTPServiceItem::ListItem()
95 FTPServiceItem::View()
98 fView
= new ServiceView("ftp", "ftpd", B_TRANSLATE("FTP server"),
99 B_TRANSLATE("The FTP server allows you to remotely access the "
100 "files on your machine using the FTP protocol.\n\nPlease note "
101 "that it is an insecure and unencrypted connection."),
110 FTPServiceItem::Revert()
112 return fView
!= NULL
? fView
->Revert() : B_OK
;
117 FTPServiceItem::IsRevertable()
119 return fView
!= NULL
? fView
->IsRevertable() : false;
124 FTPServiceItem::SettingsUpdated(uint32 which
)
127 fView
->SettingsUpdated(which
);
134 FTPServiceAddOn::FTPServiceAddOn(image_id image
,
135 BNetworkSettings
& settings
)
137 BNetworkSettingsAddOn(image
, settings
)
142 FTPServiceAddOn::~FTPServiceAddOn()
147 BNetworkSettingsItem
*
148 FTPServiceAddOn::CreateNextItem(uint32
& cookie
)
151 return new FTPServiceItem(Settings());
161 BNetworkSettingsAddOn
*
162 instantiate_network_settings_add_on(image_id image
, BNetworkSettings
& settings
)
164 return new FTPServiceAddOn(image
, settings
);