network_settings/dialup: Fix the build.

Badly needs layouting and a lot of other fixes to get it
working with the new PPP stack. But it's a start.
This commit is contained in:
Augustin Cavalier
2017-04-18 15:40:10 -04:00
parent 0a694375a9
commit 9390158822
12 changed files with 498 additions and 396 deletions
+110 -30
View File
@@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <String.h> #include <String.h>
@@ -14,32 +14,112 @@
#include <Bitmap.h> #include <Bitmap.h>
#include <Alert.h> #include <Alert.h>
#include <NetworkSetupAddOn.h> #include <NetworkSettings.h>
#include <NetworkSettingsAddOn.h>
#include "InterfaceListItem.h"
#include "DialUpView.h" #include "DialUpView.h"
class AddOn : public NetworkSetupAddOn
{
public:
AddOn(image_id addon_image);
~AddOn();
const char * Name(); using namespace BNetworkKit;
BView * CreateView(BRect *bounds);
class AddOn : public BNetworkSettingsAddOn {
public:
AddOn(image_id addon_image, BNetworkSettings& settings);
virtual ~AddOn();
virtual BNetworkSettingsItem*
CreateNextItem(uint32& cookie);
}; };
NetworkSetupAddOn * get_nth_addon(image_id image, int index) class DialUpInterfaceItem : public BNetworkSettingsItem {
{ public:
if (index == 0) DialUpInterfaceItem(BNetworkSettings& settings);
return new AddOn(image); virtual ~DialUpInterfaceItem();
return NULL;
} virtual BNetworkSettingsType
Type() const;
virtual BListItem* ListItem();
virtual BView* View();
virtual status_t Revert();
virtual bool IsRevertable();
private:
BNetworkSettings& fSettings;
BListItem* fItem;
BView* fView;
};
// #pragma mark - // #pragma mark -
AddOn::AddOn(image_id image)
: NetworkSetupAddOn(image) DialUpInterfaceItem::DialUpInterfaceItem(BNetworkSettings& settings)
:
fSettings(settings),
fItem(new InterfaceListItem("Dialup",
B_NETWORK_INTERFACE_TYPE_DIAL_UP)),
fView(NULL)
{
}
DialUpInterfaceItem::~DialUpInterfaceItem()
{
if (fView->Parent() == NULL)
delete fView;
delete fItem;
}
BNetworkSettingsType
DialUpInterfaceItem::Type() const
{
return B_NETWORK_SETTINGS_TYPE_DIAL_UP;
}
BListItem*
DialUpInterfaceItem::ListItem()
{
return fItem;
}
BView*
DialUpInterfaceItem::View()
{
if (fView == NULL)
fView = new DialUpView(BRect(0, 0, 100, 100)/*, fSettings*/);
return fView;
}
status_t
DialUpInterfaceItem::Revert()
{
return B_OK;
}
bool
DialUpInterfaceItem::IsRevertable()
{
// TODO
return false;
}
// #pragma mark -
AddOn::AddOn(image_id image, BNetworkSettings& settings)
: BNetworkSettingsAddOn(image, settings)
{ {
} }
@@ -49,22 +129,22 @@ AddOn::~AddOn()
} }
const char * AddOn::Name() BNetworkSettingsItem*
AddOn::CreateNextItem(uint32& cookie)
{ {
return "DialUp"; if (cookie++ == 0)
return new DialUpInterfaceItem(Settings());
return NULL;
} }
BView * AddOn::CreateView(BRect *bounds) // #pragma mark -
extern "C"
BNetworkSettingsAddOn*
instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings)
{ {
BRect r = *bounds; return new AddOn(image, settings);
if (r.Width() < 200 || r.Height() < 400)
r.Set(0, 0, 200, 400);
BView *view = new DialUpView(r);
*bounds = view->Bounds();
return view;
} }
@@ -75,6 +75,7 @@ ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool
BMessage parameter; BMessage parameter;
int32 index = 0; int32 index = 0;
const char *value; const char *value;
/* FIXME!
if(FindMessageParameter(PPP_DIAL_ON_DEMAND_KEY, *fSettings, &parameter, &index) if(FindMessageParameter(PPP_DIAL_ON_DEMAND_KEY, *fSettings, &parameter, &index)
&& parameter.FindString(MDSU_VALUES, &value) == B_OK) { && parameter.FindString(MDSU_VALUES, &value) == B_OK) {
if(get_boolean_value(value, false)) if(get_boolean_value(value, false))
@@ -103,6 +104,7 @@ ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool
parameter.AddBool(MDSU_VALID, true); parameter.AddBool(MDSU_VALID, true);
fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter); fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
} }
*/
if(fConnectionOptionsView) if(fConnectionOptionsView)
fConnectionOptionsView->Reload(); fConnectionOptionsView->Reload();
@@ -135,13 +137,13 @@ ConnectionOptionsAddon::SaveSettings(BMessage *settings, BMessage *profile, bool
BMessage parameter; BMessage parameter;
if(fConnectionOptionsView->DoesDialOnDemand()) { if(fConnectionOptionsView->DoesDialOnDemand()) {
parameter.MakeEmpty(); parameter.MakeEmpty();
parameter.AddString(MDSU_NAME, PPP_DIAL_ON_DEMAND_KEY); // parameter.AddString(MDSU_NAME, PPP_DIAL_ON_DEMAND_KEY); // FIXME
parameter.AddString(MDSU_VALUES, "enabled"); parameter.AddString(MDSU_VALUES, "enabled");
settings->AddMessage(MDSU_PARAMETERS, &parameter); settings->AddMessage(MDSU_PARAMETERS, &parameter);
if(fConnectionOptionsView->AskBeforeDialing()) { if(fConnectionOptionsView->AskBeforeDialing()) {
parameter.MakeEmpty(); parameter.MakeEmpty();
parameter.AddString(MDSU_NAME, PPP_ASK_BEFORE_DIALING_KEY); // parameter.AddString(MDSU_NAME, PPP_ASK_BEFORE_DIALING_KEY); // FIXME
parameter.AddString(MDSU_VALUES, "enabled"); parameter.AddString(MDSU_VALUES, "enabled");
settings->AddMessage(MDSU_PARAMETERS, &parameter); settings->AddMessage(MDSU_PARAMETERS, &parameter);
} }
@@ -149,7 +151,7 @@ ConnectionOptionsAddon::SaveSettings(BMessage *settings, BMessage *profile, bool
if(fConnectionOptionsView->DoesAutoRedial()) { if(fConnectionOptionsView->DoesAutoRedial()) {
parameter.MakeEmpty(); parameter.MakeEmpty();
parameter.AddString(MDSU_NAME, PPP_AUTO_REDIAL_KEY); // parameter.AddString(MDSU_NAME, PPP_AUTO_REDIAL_KEY); // FIXME
parameter.AddString(MDSU_VALUES, "enabled"); parameter.AddString(MDSU_VALUES, "enabled");
settings->AddMessage(MDSU_PARAMETERS, &parameter); settings->AddMessage(MDSU_PARAMETERS, &parameter);
} }
@@ -28,7 +28,7 @@
#ifndef _CONNECTION_OPTIONS_ADDON__H #ifndef _CONNECTION_OPTIONS_ADDON__H
#define _CONNECTION_OPTIONS_ADDON__H #define _CONNECTION_OPTIONS_ADDON__H
#include <DialUpAddon.h> #include "DialUpAddon.h"
#include <CheckBox.h> #include <CheckBox.h>
#include <RadioButton.h> #include <RadioButton.h>
@@ -39,6 +39,10 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include <Point.h> #include <Point.h>
class BMessage;
class BView;
class DialUpView;
#define DUN_MAXIMUM_PRIORITY 50 #define DUN_MAXIMUM_PRIORITY 50
@@ -57,7 +61,7 @@
class DialUpAddon { class DialUpAddon {
friend class DialUpView; friend class DialUpView;
public: public:
//! Constructor. The BMessage is the one passed to the \c register() function. //! Constructor. The BMessage is the one passed to the \c register() function.
@@ -461,20 +461,20 @@ DialUpView::UpDownThread()
BMessage settings, profile; BMessage settings, profile;
SaveSettings(&settings, &profile, true); SaveSettings(&settings, &profile, true);
// save temporary profile // save temporary profile
driver_settings *temporaryProfile = MessageToDriverSettings(profile); //driver_settings *temporaryProfile = MessageToDriverSettings(profile);
PPPInterface interface; PPPInterface interface;
if(fWatching == PPP_UNDEFINED_INTERFACE_ID) { if (fWatching == PPP_UNDEFINED_INTERFACE_ID) {
interface = fListener.Manager().InterfaceWithName(fCurrentItem->Label()); interface = fListener.Manager().InterfaceWithName(fCurrentItem->Label());
if(interface.InitCheck() != B_OK) if(interface.InitCheck() != B_OK)
interface = fListener.Manager().CreateInterfaceWithName( interface = fListener.Manager().CreateInterfaceWithName(
fCurrentItem->Label(), temporaryProfile); fCurrentItem->Label());
} else { } else {
interface = fWatching; interface = fWatching;
interface.SetProfile(temporaryProfile); //interface.SetProfile(temporaryProfile);
} }
free_driver_settings(temporaryProfile); //free_driver_settings(temporaryProfile);
if(interface.InitCheck() != B_OK) { if(interface.InitCheck() != B_OK) {
Window()->Lock(); Window()->Lock();
@@ -494,6 +494,7 @@ DialUpView::UpDownThread()
} }
#define PPP_INTERFACE_SETTINGS_PATH "" // FIXME!
void void
DialUpView::GetPPPDirectories(BDirectory *settingsDirectory, DialUpView::GetPPPDirectories(BDirectory *settingsDirectory,
BDirectory *profileDirectory) const BDirectory *profileDirectory) const
@@ -608,10 +609,8 @@ void
DialUpView::UpdateStatus(int32 code) DialUpView::UpdateStatus(int32 code)
{ {
switch(code) { switch(code) {
case PPP_REPORT_UP_ABORTED:
case PPP_REPORT_DEVICE_UP_FAILED: case PPP_REPORT_DEVICE_UP_FAILED:
case PPP_REPORT_LOCAL_AUTHENTICATION_FAILED: case PPP_REPORT_AUTHENTICATION_FAILED:
case PPP_REPORT_PEER_AUTHENTICATION_FAILED:
case PPP_REPORT_DOWN_SUCCESSFUL: case PPP_REPORT_DOWN_SUCCESSFUL:
case PPP_REPORT_CONNECTION_LOST: { case PPP_REPORT_CONNECTION_LOST: {
fConnectButton->SetLabel(kLabelConnect); fConnectButton->SetLabel(kLabelConnect);
@@ -643,7 +642,6 @@ DialUpView::UpdateStatus(int32 code)
fStatusView->SetText(kTextConnectionEstablished); fStatusView->SetText(kTextConnectionEstablished);
break; break;
case PPP_REPORT_UP_ABORTED:
case PPP_REPORT_DOWN_SUCCESSFUL: case PPP_REPORT_DOWN_SUCCESSFUL:
fStatusView->SetText(kTextNotConnected); fStatusView->SetText(kTextNotConnected);
break; break;
@@ -653,13 +651,11 @@ DialUpView::UpdateStatus(int32 code)
fStatusView->SetText(kTextDeviceUpFailed); fStatusView->SetText(kTextDeviceUpFailed);
break; break;
case PPP_REPORT_LOCAL_AUTHENTICATION_REQUESTED: case PPP_REPORT_AUTHENTICATION_REQUESTED:
case PPP_REPORT_PEER_AUTHENTICATION_REQUESTED:
fStatusView->SetText(kTextAuthenticating); fStatusView->SetText(kTextAuthenticating);
break; break;
case PPP_REPORT_LOCAL_AUTHENTICATION_FAILED: case PPP_REPORT_AUTHENTICATION_FAILED:
case PPP_REPORT_PEER_AUTHENTICATION_FAILED:
fKeepLabel = true; fKeepLabel = true;
fStatusView->SetText(kTextAuthenticationFailed); fStatusView->SetText(kTextAuthenticationFailed);
break; break;
@@ -678,7 +674,7 @@ DialUpView::WatchInterface(ppp_interface_id ID)
// This method can be used to update the interface's connection status. // This method can be used to update the interface's connection status.
if(fWatching != ID) { if(fWatching != ID) {
fListener.StopWatchingInterfaces(); //fListener.StopWatchingInterfaces(); // FIXME
if(ID == PPP_UNDEFINED_INTERFACE_ID || fListener.WatchInterface(ID)) if(ID == PPP_UNDEFINED_INTERFACE_ID || fListener.WatchInterface(ID))
fWatching = ID; fWatching = ID;
@@ -28,6 +28,12 @@
#include <PPPInterfaceListener.h> #include <PPPInterfaceListener.h>
class BMenuItem;
class BStringView;
class BButton;
class BPopUpMenu;
class BMenuField;
class BTabView;
class GeneralAddon; class GeneralAddon;
@@ -28,12 +28,15 @@
#ifndef _GENERAL_ADDON__H #ifndef _GENERAL_ADDON__H
#define _GENERAL_ADDON__H #define _GENERAL_ADDON__H
#include <DialUpAddon.h> #include "DialUpAddon.h"
#include <CheckBox.h> #include <CheckBox.h>
#include <String.h> #include <String.h>
#include <TextControl.h> #include <TextControl.h>
class BBox;
class BMenuField;
class BMenuItem;
class GeneralView; class GeneralView;
@@ -28,12 +28,13 @@
#ifndef _IPCP_ADDON__H #ifndef _IPCP_ADDON__H
#define _IPCP_ADDON__H #define _IPCP_ADDON__H
#include <DialUpAddon.h> #include "DialUpAddon.h"
#include <CheckBox.h> #include <CheckBox.h>
#include <String.h> #include <String.h>
#include <TextControl.h> #include <TextControl.h>
class BButton;
class IPCPView; class IPCPView;
@@ -24,12 +24,15 @@
#define _INTERFACE_UTILS__H #define _INTERFACE_UTILS__H
#include <SupportDefs.h> #include <SupportDefs.h>
#include <Point.h>
class DialUpAddon; class DialUpAddon;
class BListView; class BListView;
class BMenu; class BMenu;
class BString; class BString;
class BMenu;
class BWindow; class BWindow;
class BMessage;
extern BPoint center_on_screen(BRect rect, BWindow *window = NULL); extern BPoint center_on_screen(BRect rect, BWindow *window = NULL);
+7 -7
View File
@@ -2,14 +2,16 @@ SubDir HAIKU_TOP src add-ons network_settings dialup ;
UsePublicHeaders [ FDirName add-ons network_settings ] ; UsePublicHeaders [ FDirName add-ons network_settings ] ;
UsePrivateHeaders app libroot kernel net shared ; UsePrivateHeaders app libroot kernel net shared ;
UsePrivateSystemHeaders ;
UsePrivateKernelHeaders ; # FIXME: shouldn't be needed
UseHeaders [ FDirName $(HAIKU_TOP) src preferences network ] : false ; UseHeaders [ FDirName $(HAIKU_TOP) src preferences network ] : false ;
UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp shared libppp headers ] ; UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp shared libppp headers ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp shared libkernelppp headers ] ; UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp shared libkernelppp headers ] : true ;
# additonal headers for built-in add-ons: # additonal headers for built-in add-ons:
UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp pppoe ] ; # PPPoE UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp pppoe ] : true ; # PPPoE
UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp ipcp ] ; # IPCP UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel network ppp ipcp ] : true ; # IPCP
AddResources DialUp : DialUpPreflet.rdef ; AddResources DialUp : DialUpPreflet.rdef ;
@@ -29,12 +31,10 @@ Addon DialUpInterface :
PPPoEAddon.cpp PPPoEAddon.cpp
: be shared <nogrist>Network [ TargetLibsupc++ ] : be shared <nogrist>Network [ TargetLibsupc++ ]
[ TargetLibstdc++ ] localestub [ TargetLibstdc++ ] localestub libppp.a
; ;
DoCatalogs DialUpInterface : x-vnd.Haiku-DialUpInterface : DoCatalogs DialUpInterface : x-vnd.Haiku-DialUpInterface :
DialUpView.cpp DialUpView.cpp
; ;
#LinkSharedOSLibs DialUp : libppp.a be ;
@@ -28,11 +28,13 @@
#ifndef _PPPoE_ADDON__H #ifndef _PPPoE_ADDON__H
#define _PPPoE_ADDON__H #define _PPPoE_ADDON__H
#include <DialUpAddon.h> #include "DialUpAddon.h"
#include <String.h> #include <String.h>
#include <TextControl.h> #include <TextControl.h>
class BMenuField;
class BMenuItem;
class PPPoEView; class PPPoEView;
@@ -25,6 +25,11 @@
#include <Window.h> #include <Window.h>
class BInvoker;
class BTextView;
class BTextControl;
class BButton;
class TextRequestDialog : public BWindow { class TextRequestDialog : public BWindow {
public: public: