diff --git a/src/add-ons/network_settings/Jamfile b/src/add-ons/network_settings/Jamfile index 72abc94a1e..6c31b98615 100644 --- a/src/add-ons/network_settings/Jamfile +++ b/src/add-ons/network_settings/Jamfile @@ -9,3 +9,7 @@ SubInclude HAIKU_TOP src add-ons network_settings dnsclient ; 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 ; + +# VPN add-ons +SubInclude HAIKU_TOP src add-ons network_settings openvpn ; + diff --git a/src/add-ons/network_settings/openvpn/Jamfile b/src/add-ons/network_settings/openvpn/Jamfile new file mode 100644 index 0000000000..6bc04c3d4f --- /dev/null +++ b/src/add-ons/network_settings/openvpn/Jamfile @@ -0,0 +1,18 @@ +SubDir HAIKU_TOP src add-ons network_settings openvpn ; + +UsePublicHeaders [ FDirName add-ons network_settings ] ; +UsePrivateHeaders app libroot kernel net shared ; +UseHeaders [ FDirName $(HAIKU_TOP) src preferences network ] : false ; + +AddResources OpenVPN : OpenVPN.rdef ; + +Addon OpenVPNInterface : + OpenVPNInterfaceAddOn.cpp + + : be bnetapi shared Network [ TargetLibsupc++ ] + [ TargetLibstdc++ ] localestub +; + +DoCatalogs OpenVPNInterface : x-vnd.Haiku-OpenVPNInterface : + OpenVPNInterfaceAddOn.cpp +; diff --git a/src/add-ons/network_settings/openvpn/OpenVPN.rdef b/src/add-ons/network_settings/openvpn/OpenVPN.rdef new file mode 100644 index 0000000000..ce4514df9f --- /dev/null +++ b/src/add-ons/network_settings/openvpn/OpenVPN.rdef @@ -0,0 +1,12 @@ +resource app_signature "application/x-vnd.Haiku-SSHService"; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + variety = 0, + internal = 0, + short_info = "1.0.0", + long_info = "Haiku SSH server settings" +}; + diff --git a/src/add-ons/network_settings/openvpn/OpenVPNInterfaceAddOn.cpp b/src/add-ons/network_settings/openvpn/OpenVPNInterfaceAddOn.cpp new file mode 100644 index 0000000000..2822696880 --- /dev/null +++ b/src/add-ons/network_settings/openvpn/OpenVPNInterfaceAddOn.cpp @@ -0,0 +1,189 @@ +/* + * Copyright 2015-2017 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, + * Ingo Weinhold + * Alexander von Gluck IV + */ + + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "InterfaceListItem.h" +#include "InterfaceView.h" + + +using namespace BNetworkKit; + + +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "OpenVPNInterfaceAddOn" + + +static const uint32 kMsgToggleService = 'tgls'; + + +class OpenVPNInterfaceAddOn : public BNetworkSettingsAddOn { +public: + OpenVPNInterfaceAddOn(image_id image, + BNetworkSettings& settings); + virtual ~OpenVPNInterfaceAddOn(); + + virtual BNetworkSettingsItem* + CreateNextItem(uint32& cookie); +}; + + +class OpenVPNInterfaceView : public InterfaceView { +public: + OpenVPNInterfaceView(BNetworkSettings& settings); + virtual ~OpenVPNInterfaceView(); +}; + + +class OpenVPNInterfaceItem : public BNetworkSettingsItem { +public: + OpenVPNInterfaceItem(BNetworkSettings& settings); + virtual ~OpenVPNInterfaceItem(); + + virtual BNetworkSettingsType + Type() const; + + virtual BListItem* ListItem(); + virtual BView* View(); + + virtual status_t Revert(); + virtual bool IsRevertable(); + +private: + BNetworkSettings& fSettings; + BListItem* fItem; + InterfaceView* fView; +}; + + +// #pragma mark - + + +OpenVPNInterfaceView::OpenVPNInterfaceView(BNetworkSettings& settings) + : + InterfaceView() +{ +} + + +OpenVPNInterfaceView::~OpenVPNInterfaceView() +{ +} + + +// #pragma mark - + + +OpenVPNInterfaceItem::OpenVPNInterfaceItem(BNetworkSettings& settings) + : + fSettings(settings), + fItem(new InterfaceListItem("My Awesome VPN", + B_NETWORK_INTERFACE_TYPE_VPN)), + fView(NULL) +{ +} + + +OpenVPNInterfaceItem::~OpenVPNInterfaceItem() +{ + if (fView->Parent() == NULL) + delete fView; + + delete fItem; +} + + +BNetworkSettingsType +OpenVPNInterfaceItem::Type() const +{ + return B_NETWORK_SETTINGS_TYPE_VPN; +} + + +BListItem* +OpenVPNInterfaceItem::ListItem() +{ + return fItem; +} + + +BView* +OpenVPNInterfaceItem::View() +{ + if (fView == NULL) + fView = new OpenVPNInterfaceView(fSettings); + + return fView; +} + + +status_t +OpenVPNInterfaceItem::Revert() +{ + return B_OK; +} + +bool +OpenVPNInterfaceItem::IsRevertable() +{ + // TODO + return false; +} + + +// #pragma mark - + + +OpenVPNInterfaceAddOn::OpenVPNInterfaceAddOn(image_id image, + BNetworkSettings& settings) + : + BNetworkSettingsAddOn(image, settings) +{ +} + + +OpenVPNInterfaceAddOn::~OpenVPNInterfaceAddOn() +{ +} + + +BNetworkSettingsItem* +OpenVPNInterfaceAddOn::CreateNextItem(uint32& cookie) +{ + if (cookie++ == 0) + return new OpenVPNInterfaceItem(Settings()); + + return NULL; +} + + +// #pragma mark - + + +extern "C" +BNetworkSettingsAddOn* +instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings) +{ + return new OpenVPNInterfaceAddOn(image, settings); +}