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 "TelnetServiceAddOn"
25 class TelnetServiceAddOn
: public BNetworkSettingsAddOn
{
27 TelnetServiceAddOn(image_id image
,
28 BNetworkSettings
& settings
);
29 virtual ~TelnetServiceAddOn();
31 virtual BNetworkSettingsItem
*
32 CreateNextItem(uint32
& cookie
);
36 class TelnetServiceItem
: public BNetworkSettingsItem
{
38 TelnetServiceItem(BNetworkSettings
& settings
);
39 virtual ~TelnetServiceItem();
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 TelnetServiceItem::TelnetServiceItem(BNetworkSettings
& settings
)
65 fItem(new ServiceListItem("telnet", B_TRANSLATE("Telnet server"),
72 TelnetServiceItem::~TelnetServiceItem()
74 if (fView
->Parent() == NULL
)
82 TelnetServiceItem::Type() const
84 return B_NETWORK_SETTINGS_TYPE_SERVICE
;
89 TelnetServiceItem::ListItem()
96 TelnetServiceItem::View()
99 fView
= new ServiceView("telnet", "telnetd",
100 B_TRANSLATE("Telnet server"),
101 B_TRANSLATE("The Telnet server allows you to remotely access "
102 "your machine with a terminal session using the telnet "
103 "protocol.\n\nPlease note that it is an insecure and "
104 "unencrypted connection."), fSettings
);
112 TelnetServiceItem::Revert()
114 return fView
!= NULL
? fView
->Revert() : B_OK
;
119 TelnetServiceItem::IsRevertable()
121 return fView
!= NULL
? fView
->IsRevertable() : false;
126 TelnetServiceItem::SettingsUpdated(uint32 which
)
129 fView
->SettingsUpdated(which
);
136 TelnetServiceAddOn::TelnetServiceAddOn(image_id image
,
137 BNetworkSettings
& settings
)
139 BNetworkSettingsAddOn(image
, settings
)
144 TelnetServiceAddOn::~TelnetServiceAddOn()
149 BNetworkSettingsItem
*
150 TelnetServiceAddOn::CreateNextItem(uint32
& cookie
)
153 return new TelnetServiceItem(Settings());
163 BNetworkSettingsAddOn
*
164 instantiate_network_settings_add_on(image_id image
, BNetworkSettings
& settings
)
166 return new TelnetServiceAddOn(image
, settings
);