BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / network_settings / telnetd / TelnetServiceAddOn.cpp
blobf3de11eb7172fa3e46bb192236bbded8457a9691
1 /*
2 * Copyright 2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, <axeld@pinc-software.de>
7 */
10 #include <Catalog.h>
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 {
26 public:
27 TelnetServiceAddOn(image_id image,
28 BNetworkSettings& settings);
29 virtual ~TelnetServiceAddOn();
31 virtual BNetworkSettingsItem*
32 CreateNextItem(uint32& cookie);
36 class TelnetServiceItem : public BNetworkSettingsItem {
37 public:
38 TelnetServiceItem(BNetworkSettings& settings);
39 virtual ~TelnetServiceItem();
41 virtual BNetworkSettingsType
42 Type() const;
44 virtual BListItem* ListItem();
45 virtual BView* View();
47 virtual status_t Revert();
48 virtual bool IsRevertable();
50 virtual void SettingsUpdated(uint32 which);
52 private:
53 BNetworkSettings& fSettings;
54 BListItem* fItem;
55 ServiceView* fView;
59 // #pragma mark -
62 TelnetServiceItem::TelnetServiceItem(BNetworkSettings& settings)
64 fSettings(settings),
65 fItem(new ServiceListItem("telnet", B_TRANSLATE("Telnet server"),
66 settings)),
67 fView(NULL)
72 TelnetServiceItem::~TelnetServiceItem()
74 if (fView->Parent() == NULL)
75 delete fView;
77 delete fItem;
81 BNetworkSettingsType
82 TelnetServiceItem::Type() const
84 return B_NETWORK_SETTINGS_TYPE_SERVICE;
88 BListItem*
89 TelnetServiceItem::ListItem()
91 return fItem;
95 BView*
96 TelnetServiceItem::View()
98 if (fView == NULL) {
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);
107 return fView;
111 status_t
112 TelnetServiceItem::Revert()
114 return fView != NULL ? fView->Revert() : B_OK;
118 bool
119 TelnetServiceItem::IsRevertable()
121 return fView != NULL ? fView->IsRevertable() : false;
125 void
126 TelnetServiceItem::SettingsUpdated(uint32 which)
128 if (fView != NULL)
129 fView->SettingsUpdated(which);
133 // #pragma mark -
136 TelnetServiceAddOn::TelnetServiceAddOn(image_id image,
137 BNetworkSettings& settings)
139 BNetworkSettingsAddOn(image, settings)
144 TelnetServiceAddOn::~TelnetServiceAddOn()
149 BNetworkSettingsItem*
150 TelnetServiceAddOn::CreateNextItem(uint32& cookie)
152 if (cookie++ == 0)
153 return new TelnetServiceItem(Settings());
155 return NULL;
159 // #pragma mark -
162 extern "C"
163 BNetworkSettingsAddOn*
164 instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings)
166 return new TelnetServiceAddOn(image, settings);