network preflet: Introduce early OpenVPN add-on

* Not included in image... will likely be quite some
  time until it is :-)
This commit is contained in:
Alexander von Gluck IV 2017-04-05 18:50:00 +00:00
parent 6516aed58b
commit 5c08c83412
4 changed files with 223 additions and 0 deletions

View File

@ -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 ;

View File

@ -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 <nogrist>Network [ TargetLibsupc++ ]
[ TargetLibstdc++ ] localestub
;
DoCatalogs OpenVPNInterface : x-vnd.Haiku-OpenVPNInterface :
OpenVPNInterfaceAddOn.cpp
;

View File

@ -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"
};

View File

@ -0,0 +1,189 @@
/*
* Copyright 2015-2017 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, <axeld@pinc-software.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
* Alexander von Gluck IV <kallisti5@unixzen.com>
*/
#include <pwd.h>
#include <Button.h>
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <NetworkSettings.h>
#include <NetworkSettingsAddOn.h>
#include <StringView.h>
#include <TextView.h>
#include <NetServer.h>
#include <RegistrarDefs.h>
#include <user_group.h>
#include <util/KMessage.h>
#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);
}