diff --git a/src/add-ons/network_settings/Jamfile b/src/add-ons/network_settings/Jamfile index c9b5846d3b..df06381af6 100644 --- a/src/add-ons/network_settings/Jamfile +++ b/src/add-ons/network_settings/Jamfile @@ -1,5 +1,10 @@ SubDir HAIKU_TOP src add-ons network_settings ; +# Interface add-ons SubInclude HAIKU_TOP src add-ons network_settings ipv4 ; SubInclude HAIKU_TOP src add-ons network_settings ipv6 ; + +# Service add-ons +SubInclude HAIKU_TOP src add-ons network_settings ftpd ; SubInclude HAIKU_TOP src add-ons network_settings sshd ; +SubInclude HAIKU_TOP src add-ons network_settings telnetd ; diff --git a/src/add-ons/network_settings/ftpd/FTPServiceAddOn.cpp b/src/add-ons/network_settings/ftpd/FTPServiceAddOn.cpp new file mode 100644 index 0000000000..93859a1225 --- /dev/null +++ b/src/add-ons/network_settings/ftpd/FTPServiceAddOn.cpp @@ -0,0 +1,165 @@ +/* + * Copyright 2015 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, + */ + + +#include +#include +#include +#include + +#include "ServiceView.h" + + +using namespace BNetworkKit; + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "FTPServiceAddOn" + + +class FTPServiceAddOn : public BNetworkSettingsAddOn { +public: + FTPServiceAddOn(image_id image, + BNetworkSettings& settings); + virtual ~FTPServiceAddOn(); + + virtual BNetworkSettingsItem* + CreateNextItem(uint32& cookie); +}; + + +class FTPServiceItem : public BNetworkSettingsItem { +public: + FTPServiceItem(BNetworkSettings& settings); + virtual ~FTPServiceItem(); + + virtual BNetworkSettingsType + Type() const; + + virtual BListItem* ListItem(); + virtual BView* View(); + + virtual status_t Revert(); + virtual bool IsRevertable(); + + virtual void SettingsUpdated(uint32 which); + +private: + BNetworkSettings& fSettings; + BStringItem* fItem; + ServiceView* fView; +}; + + +// #pragma mark - + + +FTPServiceItem::FTPServiceItem(BNetworkSettings& settings) + : + fSettings(settings), + fItem(new BStringItem(B_TRANSLATE("FTP server"))), + fView(NULL) +{ +} + + +FTPServiceItem::~FTPServiceItem() +{ + if (fView->Parent() == NULL) + delete fView; + + delete fItem; +} + + +BNetworkSettingsType +FTPServiceItem::Type() const +{ + return B_NETWORK_SETTINGS_TYPE_SERVICE; +} + + +BListItem* +FTPServiceItem::ListItem() +{ + return fItem; +} + + +BView* +FTPServiceItem::View() +{ + if (fView == NULL) { + fView = new ServiceView("ftp", "ftpd", B_TRANSLATE("FTP server"), + B_TRANSLATE("The FTP server allows you to remotely access the " + "files on your machine using the FTP protocol.\n\nPlease note " + "that it is an insecure and unencrypted connection."), + fSettings); + } + + return fView; +} + + +status_t +FTPServiceItem::Revert() +{ + return B_OK; +} + + +bool +FTPServiceItem::IsRevertable() +{ + return false; +} + + +void +FTPServiceItem::SettingsUpdated(uint32 which) +{ + if (fView != NULL) + fView->SettingsUpdated(which); +} + + +// #pragma mark - + + +FTPServiceAddOn::FTPServiceAddOn(image_id image, + BNetworkSettings& settings) + : + BNetworkSettingsAddOn(image, settings) +{ +} + + +FTPServiceAddOn::~FTPServiceAddOn() +{ +} + + +BNetworkSettingsItem* +FTPServiceAddOn::CreateNextItem(uint32& cookie) +{ + if (cookie++ == 0) + return new FTPServiceItem(Settings()); + + return NULL; +} + + +// #pragma mark - + + +extern "C" +BNetworkSettingsAddOn* +instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings) +{ + return new FTPServiceAddOn(image, settings); +} diff --git a/src/add-ons/network_settings/ftpd/Jamfile b/src/add-ons/network_settings/ftpd/Jamfile new file mode 100644 index 0000000000..b2b64b7aa6 --- /dev/null +++ b/src/add-ons/network_settings/ftpd/Jamfile @@ -0,0 +1,19 @@ +SubDir HAIKU_TOP src add-ons network_settings ftpd ; + +UsePublicHeaders [ FDirName add-ons network_settings ] ; +UsePrivateHeaders app libroot kernel net shared ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons network_settings sshd ] ; + +Addon FTPService : + FTPServiceAddOn.cpp + ServiceView.cpp + + : be bnetapi libshared.a Network [ TargetLibsupc++ ] + [ TargetLibstdc++ ] localestub +; + +DoCatalogs FTPService : x-vnd.Haiku-FTPService : + FTPServiceAddOn.cpp + ServiceView.cpp +; diff --git a/src/add-ons/network_settings/telnetd/Jamfile b/src/add-ons/network_settings/telnetd/Jamfile new file mode 100644 index 0000000000..7c8ea9b887 --- /dev/null +++ b/src/add-ons/network_settings/telnetd/Jamfile @@ -0,0 +1,19 @@ +SubDir HAIKU_TOP src add-ons network_settings telnetd ; + +UsePublicHeaders [ FDirName add-ons network_settings ] ; +UsePrivateHeaders app libroot kernel net shared ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons network_settings sshd ] ; + +Addon TelnetService : + TelnetServiceAddOn.cpp + ServiceView.cpp + + : be bnetapi libshared.a Network [ TargetLibsupc++ ] + [ TargetLibstdc++ ] localestub +; + +DoCatalogs TelnetService : x-vnd.Haiku-TelnetService : + TelnetServiceAddOn.cpp + ServiceView.cpp +; diff --git a/src/add-ons/network_settings/telnetd/TelnetServiceAddOn.cpp b/src/add-ons/network_settings/telnetd/TelnetServiceAddOn.cpp new file mode 100644 index 0000000000..59cbd54f7e --- /dev/null +++ b/src/add-ons/network_settings/telnetd/TelnetServiceAddOn.cpp @@ -0,0 +1,166 @@ +/* + * Copyright 2015 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, + */ + + +#include +#include +#include +#include + +#include "ServiceView.h" + + +using namespace BNetworkKit; + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "TelnetServiceAddOn" + + +class TelnetServiceAddOn : public BNetworkSettingsAddOn { +public: + TelnetServiceAddOn(image_id image, + BNetworkSettings& settings); + virtual ~TelnetServiceAddOn(); + + virtual BNetworkSettingsItem* + CreateNextItem(uint32& cookie); +}; + + +class TelnetServiceItem : public BNetworkSettingsItem { +public: + TelnetServiceItem(BNetworkSettings& settings); + virtual ~TelnetServiceItem(); + + virtual BNetworkSettingsType + Type() const; + + virtual BListItem* ListItem(); + virtual BView* View(); + + virtual status_t Revert(); + virtual bool IsRevertable(); + + virtual void SettingsUpdated(uint32 which); + +private: + BNetworkSettings& fSettings; + BStringItem* fItem; + ServiceView* fView; +}; + + +// #pragma mark - + + +TelnetServiceItem::TelnetServiceItem(BNetworkSettings& settings) + : + fSettings(settings), + fItem(new BStringItem(B_TRANSLATE("Telnet server"))), + fView(NULL) +{ +} + + +TelnetServiceItem::~TelnetServiceItem() +{ + if (fView->Parent() == NULL) + delete fView; + + delete fItem; +} + + +BNetworkSettingsType +TelnetServiceItem::Type() const +{ + return B_NETWORK_SETTINGS_TYPE_SERVICE; +} + + +BListItem* +TelnetServiceItem::ListItem() +{ + return fItem; +} + + +BView* +TelnetServiceItem::View() +{ + if (fView == NULL) { + fView = new ServiceView("telnet", "telnetd", + B_TRANSLATE("Telnet server"), + B_TRANSLATE("The Telnet server allows you to remotely access " + "your machine with a terminal session using the telnet " + "protocol.\n\nPlease note that it is an insecure and " + "unencrypted connection."), fSettings); + } + + return fView; +} + + +status_t +TelnetServiceItem::Revert() +{ + return B_OK; +} + + +bool +TelnetServiceItem::IsRevertable() +{ + return false; +} + + +void +TelnetServiceItem::SettingsUpdated(uint32 which) +{ + if (fView != NULL) + fView->SettingsUpdated(which); +} + + +// #pragma mark - + + +TelnetServiceAddOn::TelnetServiceAddOn(image_id image, + BNetworkSettings& settings) + : + BNetworkSettingsAddOn(image, settings) +{ +} + + +TelnetServiceAddOn::~TelnetServiceAddOn() +{ +} + + +BNetworkSettingsItem* +TelnetServiceAddOn::CreateNextItem(uint32& cookie) +{ + if (cookie++ == 0) + return new TelnetServiceItem(Settings()); + + return NULL; +} + + +// #pragma mark - + + +extern "C" +BNetworkSettingsAddOn* +instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings) +{ + return new TelnetServiceAddOn(image, settings); +}