1a6f0a920SAxel Dörfler /*
2a6f0a920SAxel Dörfler * Copyright 2015 Haiku, Inc. All rights reserved.
3a6f0a920SAxel Dörfler * Distributed under the terms of the MIT License.
4a6f0a920SAxel Dörfler *
5a6f0a920SAxel Dörfler * Authors:
6a6f0a920SAxel Dörfler * Axel Dörfler, <axeld@pinc-software.de>
7a6f0a920SAxel Dörfler */
8a6f0a920SAxel Dörfler
9a6f0a920SAxel Dörfler
10a6f0a920SAxel Dörfler #include <Catalog.h>
11a6f0a920SAxel Dörfler #include <NetworkSettings.h>
12a6f0a920SAxel Dörfler #include <NetworkSettingsAddOn.h>
13a6f0a920SAxel Dörfler
143d3eb8daSAxel Dörfler #include "ServiceListItem.h"
15a6f0a920SAxel Dörfler #include "ServiceView.h"
16a6f0a920SAxel Dörfler
17a6f0a920SAxel Dörfler
18a6f0a920SAxel Dörfler using namespace BNetworkKit;
19a6f0a920SAxel Dörfler
20a6f0a920SAxel Dörfler
21a6f0a920SAxel Dörfler #undef B_TRANSLATION_CONTEXT
22a6f0a920SAxel Dörfler #define B_TRANSLATION_CONTEXT "TelnetServiceAddOn"
23a6f0a920SAxel Dörfler
24a6f0a920SAxel Dörfler
25a6f0a920SAxel Dörfler class TelnetServiceAddOn : public BNetworkSettingsAddOn {
26a6f0a920SAxel Dörfler public:
27a6f0a920SAxel Dörfler TelnetServiceAddOn(image_id image,
28a6f0a920SAxel Dörfler BNetworkSettings& settings);
29a6f0a920SAxel Dörfler virtual ~TelnetServiceAddOn();
30a6f0a920SAxel Dörfler
31a6f0a920SAxel Dörfler virtual BNetworkSettingsItem*
32a6f0a920SAxel Dörfler CreateNextItem(uint32& cookie);
33a6f0a920SAxel Dörfler };
34a6f0a920SAxel Dörfler
35a6f0a920SAxel Dörfler
36a6f0a920SAxel Dörfler class TelnetServiceItem : public BNetworkSettingsItem {
37a6f0a920SAxel Dörfler public:
38a6f0a920SAxel Dörfler TelnetServiceItem(BNetworkSettings& settings);
39a6f0a920SAxel Dörfler virtual ~TelnetServiceItem();
40a6f0a920SAxel Dörfler
41a6f0a920SAxel Dörfler virtual BNetworkSettingsType
42a6f0a920SAxel Dörfler Type() const;
43a6f0a920SAxel Dörfler
44a6f0a920SAxel Dörfler virtual BListItem* ListItem();
45a6f0a920SAxel Dörfler virtual BView* View();
46a6f0a920SAxel Dörfler
47a6f0a920SAxel Dörfler virtual status_t Revert();
48a6f0a920SAxel Dörfler virtual bool IsRevertable();
49a6f0a920SAxel Dörfler
50a6f0a920SAxel Dörfler virtual void SettingsUpdated(uint32 which);
51a6f0a920SAxel Dörfler
52a6f0a920SAxel Dörfler private:
53a6f0a920SAxel Dörfler BNetworkSettings& fSettings;
543d3eb8daSAxel Dörfler BListItem* fItem;
55a6f0a920SAxel Dörfler ServiceView* fView;
56a6f0a920SAxel Dörfler };
57a6f0a920SAxel Dörfler
58a6f0a920SAxel Dörfler
59a6f0a920SAxel Dörfler // #pragma mark -
60a6f0a920SAxel Dörfler
61a6f0a920SAxel Dörfler
TelnetServiceItem(BNetworkSettings & settings)62a6f0a920SAxel Dörfler TelnetServiceItem::TelnetServiceItem(BNetworkSettings& settings)
63a6f0a920SAxel Dörfler :
64a6f0a920SAxel Dörfler fSettings(settings),
653d3eb8daSAxel Dörfler fItem(new ServiceListItem("telnet", B_TRANSLATE("Telnet server"),
663d3eb8daSAxel Dörfler settings)),
67a6f0a920SAxel Dörfler fView(NULL)
68a6f0a920SAxel Dörfler {
69a6f0a920SAxel Dörfler }
70a6f0a920SAxel Dörfler
71a6f0a920SAxel Dörfler
~TelnetServiceItem()72a6f0a920SAxel Dörfler TelnetServiceItem::~TelnetServiceItem()
73a6f0a920SAxel Dörfler {
74a6f0a920SAxel Dörfler if (fView->Parent() == NULL)
75a6f0a920SAxel Dörfler delete fView;
76a6f0a920SAxel Dörfler
77a6f0a920SAxel Dörfler delete fItem;
78a6f0a920SAxel Dörfler }
79a6f0a920SAxel Dörfler
80a6f0a920SAxel Dörfler
81a6f0a920SAxel Dörfler BNetworkSettingsType
Type() const82a6f0a920SAxel Dörfler TelnetServiceItem::Type() const
83a6f0a920SAxel Dörfler {
84a6f0a920SAxel Dörfler return B_NETWORK_SETTINGS_TYPE_SERVICE;
85a6f0a920SAxel Dörfler }
86a6f0a920SAxel Dörfler
87a6f0a920SAxel Dörfler
88a6f0a920SAxel Dörfler BListItem*
ListItem()89a6f0a920SAxel Dörfler TelnetServiceItem::ListItem()
90a6f0a920SAxel Dörfler {
91a6f0a920SAxel Dörfler return fItem;
92a6f0a920SAxel Dörfler }
93a6f0a920SAxel Dörfler
94a6f0a920SAxel Dörfler
95a6f0a920SAxel Dörfler BView*
View()96a6f0a920SAxel Dörfler TelnetServiceItem::View()
97a6f0a920SAxel Dörfler {
98a6f0a920SAxel Dörfler if (fView == NULL) {
99a6f0a920SAxel Dörfler fView = new ServiceView("telnet", "telnetd",
100a6f0a920SAxel Dörfler B_TRANSLATE("Telnet server"),
101a6f0a920SAxel Dörfler B_TRANSLATE("The Telnet server allows you to remotely access "
102a6f0a920SAxel Dörfler "your machine with a terminal session using the telnet "
103a6f0a920SAxel Dörfler "protocol.\n\nPlease note that it is an insecure and "
104a6f0a920SAxel Dörfler "unencrypted connection."), fSettings);
105a6f0a920SAxel Dörfler }
106a6f0a920SAxel Dörfler
107a6f0a920SAxel Dörfler return fView;
108a6f0a920SAxel Dörfler }
109a6f0a920SAxel Dörfler
110a6f0a920SAxel Dörfler
111a6f0a920SAxel Dörfler status_t
Revert()112a6f0a920SAxel Dörfler TelnetServiceItem::Revert()
113a6f0a920SAxel Dörfler {
114*6a290205SAxel Dörfler return fView != NULL ? fView->Revert() : B_OK;
115a6f0a920SAxel Dörfler }
116a6f0a920SAxel Dörfler
117a6f0a920SAxel Dörfler
118a6f0a920SAxel Dörfler bool
IsRevertable()119a6f0a920SAxel Dörfler TelnetServiceItem::IsRevertable()
120a6f0a920SAxel Dörfler {
121*6a290205SAxel Dörfler return fView != NULL ? fView->IsRevertable() : false;
122a6f0a920SAxel Dörfler }
123a6f0a920SAxel Dörfler
124a6f0a920SAxel Dörfler
125a6f0a920SAxel Dörfler void
SettingsUpdated(uint32 which)126a6f0a920SAxel Dörfler TelnetServiceItem::SettingsUpdated(uint32 which)
127a6f0a920SAxel Dörfler {
128a6f0a920SAxel Dörfler if (fView != NULL)
129a6f0a920SAxel Dörfler fView->SettingsUpdated(which);
130a6f0a920SAxel Dörfler }
131a6f0a920SAxel Dörfler
132a6f0a920SAxel Dörfler
133a6f0a920SAxel Dörfler // #pragma mark -
134a6f0a920SAxel Dörfler
135a6f0a920SAxel Dörfler
TelnetServiceAddOn(image_id image,BNetworkSettings & settings)136a6f0a920SAxel Dörfler TelnetServiceAddOn::TelnetServiceAddOn(image_id image,
137a6f0a920SAxel Dörfler BNetworkSettings& settings)
138a6f0a920SAxel Dörfler :
139a6f0a920SAxel Dörfler BNetworkSettingsAddOn(image, settings)
140a6f0a920SAxel Dörfler {
141a6f0a920SAxel Dörfler }
142a6f0a920SAxel Dörfler
143a6f0a920SAxel Dörfler
~TelnetServiceAddOn()144a6f0a920SAxel Dörfler TelnetServiceAddOn::~TelnetServiceAddOn()
145a6f0a920SAxel Dörfler {
146a6f0a920SAxel Dörfler }
147a6f0a920SAxel Dörfler
148a6f0a920SAxel Dörfler
149a6f0a920SAxel Dörfler BNetworkSettingsItem*
CreateNextItem(uint32 & cookie)150a6f0a920SAxel Dörfler TelnetServiceAddOn::CreateNextItem(uint32& cookie)
151a6f0a920SAxel Dörfler {
152a6f0a920SAxel Dörfler if (cookie++ == 0)
153a6f0a920SAxel Dörfler return new TelnetServiceItem(Settings());
154a6f0a920SAxel Dörfler
155a6f0a920SAxel Dörfler return NULL;
156a6f0a920SAxel Dörfler }
157a6f0a920SAxel Dörfler
158a6f0a920SAxel Dörfler
159a6f0a920SAxel Dörfler // #pragma mark -
160a6f0a920SAxel Dörfler
161a6f0a920SAxel Dörfler
162a6f0a920SAxel Dörfler extern "C"
163a6f0a920SAxel Dörfler BNetworkSettingsAddOn*
instantiate_network_settings_add_on(image_id image,BNetworkSettings & settings)164a6f0a920SAxel Dörfler instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings)
165a6f0a920SAxel Dörfler {
166a6f0a920SAxel Dörfler return new TelnetServiceAddOn(image, settings);
167a6f0a920SAxel Dörfler }
168