Put module and settings handling into libptpnet.a. This is the beginning of the userland part of our PTP (Point-To-Point interfaces) library which is responsible for every kind of connection kind that has exactly two endpoints.

Some other changes I do not remember.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10116 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Waldemar Kornewald
2004-11-21 12:52:19 +00:00
parent dbf0699fad
commit c18c171835
19 changed files with 159 additions and 738 deletions
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// ConnectionOptionsAddon saves the loaded settings.
@@ -46,8 +29,8 @@ static const char *kLabelAutoRedial = "Verbindung Automatisch Wiederherstellen";
#else
static const char *kLabelConnectionOptions = "Options";
static const char *kLabelDialOnDemand = "Connect Automatically When Needed";
static const char *kLabelAskBeforeDialing = "Ask Before Dialing";
static const char *kLabelAutoRedial = "Redial Automatically";
static const char *kLabelAskBeforeDialing = "Ask Before Connecting";
static const char *kLabelAutoRedial = "Reconnect Automatically";
#endif
@@ -57,11 +40,15 @@ ConnectionOptionsAddon::ConnectionOptionsAddon(BMessage *addons)
fProfile(NULL),
fConnectionOptionsView(NULL)
{
CreateView(BPoint(0,0));
fDeleteView = true;
}
ConnectionOptionsAddon::~ConnectionOptionsAddon()
{
if(fDeleteView)
delete fConnectionOptionsView;
}
@@ -73,9 +60,8 @@ ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool
fSettings = settings;
fProfile = profile;
if(fConnectionOptionsView)
fConnectionOptionsView->Reload();
// reset all views (empty settings)
fConnectionOptionsView->Reload();
// reset all views (empty settings)
if(!settings || !profile || isNew)
return true;
@@ -112,9 +98,8 @@ ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool
fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
}
if(fConnectionOptionsView)
fConnectionOptionsView->Reload();
// reload new settings
fConnectionOptionsView->Reload();
// reload new settings
return true;
}
@@ -135,7 +120,8 @@ ConnectionOptionsAddon::IsModified(bool *settings, bool *profile) const
bool
ConnectionOptionsAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporary)
ConnectionOptionsAddon::SaveSettings(BMessage *settings, BMessage *profile,
bool saveTemporary)
{
if(!fSettings || !settings)
return false;
@@ -190,10 +176,12 @@ ConnectionOptionsAddon::CreateView(BPoint leftTop)
BRect rect;
Addons()->FindRect(DUN_TAB_VIEW_RECT, &rect);
fConnectionOptionsView = new ConnectionOptionsView(this, rect);
fConnectionOptionsView->Reload();
}
fDeleteView = false;
fConnectionOptionsView->MoveTo(leftTop);
fConnectionOptionsView->Reload();
return fConnectionOptionsView;
}
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// ConnectionOptionsAddon saves the loaded settings.
@@ -66,7 +49,7 @@ class ConnectionOptionsAddon : public DialUpAddon {
virtual BView *CreateView(BPoint leftTop);
private:
bool fIsNew;
bool fIsNew, fDeleteView;
bool fDoesDialOnDemand, fAskBeforeDialing, fDoesAutoRedial;
BMessage *fSettings, *fProfile;
// saves last settings state
+4 -21
View File
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
/*! \class DialUpAddon
\brief Base class for DialUpPreflet add-ons.
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <Window.h>
+20 -286
View File
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
* Distributed under the terms of the MIT License.
*/
#include "DialUpView.h"
#include "DialUpAddon.h"
@@ -28,12 +11,6 @@
#include "MessageDriverSettingsUtils.h"
#include "TextRequestDialog.h"
// built-in add-ons
#include "ConnectionOptionsAddon.h"
#include "GeneralAddon.h"
#include "IPCPAddon.h"
#include "PPPoEAddon.h"
#include <PPPInterface.h>
#include <settings_tools.h>
#include <TemplateList.h>
@@ -51,7 +28,6 @@
#include <Directory.h>
#include <Entry.h>
#include <File.h>
#include <Path.h>
@@ -145,7 +121,6 @@ DialUpView::DialUpView(BRect frame)
: BView(frame, "DialUpView", B_FOLLOW_NONE, 0),
fListener(this),
fUpDownThread(-1),
fDriverSettings(NULL),
fCurrentItem(NULL),
fWatching(PPP_UNDEFINED_INTERFACE_ID),
fKeepLabel(false)
@@ -156,7 +131,7 @@ DialUpView::DialUpView(BRect frame)
// add messenger to us so add-ons can contact us
BMessenger messenger(this);
fAddons.AddMessenger(DUN_MESSENGER, messenger);
fSettings.Addons().AddMessenger(DUN_MESSENGER, messenger);
// create pop-up with all interfaces and "New..."/"Delete current" items
fInterfaceMenu = new BPopUpMenu(kLabelCreateNew);
@@ -173,7 +148,7 @@ DialUpView::DialUpView(BRect frame)
fTabView = new BTabView(rect, "TabView", B_WIDTH_FROM_LABEL);
BRect tabViewRect(fTabView->Bounds());
tabViewRect.bottom -= fTabView->TabHeight();
fAddons.AddRect(DUN_TAB_VIEW_RECT, tabViewRect);
fSettings.Addons().AddRect(DUN_TAB_VIEW_RECT, tabViewRect);
BRect tmpRect(rect);
tmpRect.top += (tmpRect.Height() - 15) / 2;
@@ -211,7 +186,7 @@ DialUpView::DialUpView(BRect frame)
// initialize
LoadInterfaces();
LoadAddons();
fSettings.LoadAddons();
CreateTabs();
fCurrentItem = NULL;
// reset, otherwise SelectInterface will not load the settings
@@ -222,18 +197,10 @@ DialUpView::DialUpView(BRect frame)
DialUpView::~DialUpView()
{
SaveSettingsToFile();
fSettings.SaveSettingsToFile();
int32 tmp;
wait_for_thread(fUpDownThread, &tmp);
// free known add-on types (these should free their known add-on types, etc.)
DialUpAddon *addon;
for(int32 index = 0;
fAddons.FindPointer(DUN_DELETE_ON_QUIT, index,
reinterpret_cast<void**>(&addon)) == B_OK;
index++)
delete addon;
}
@@ -285,7 +252,7 @@ DialUpView::MessageReceived(BMessage *message)
fInterfaceMenu->RemoveItem(fCurrentItem);
BDirectory settings, profile;
GetPPPDirectories(&settings, &profile);
fSettings.GetPTPDirectories(&settings, &profile);
BEntry entry;
settings.FindEntry(fCurrentItem->Label(), &entry);
entry.Remove();
@@ -324,179 +291,12 @@ DialUpView::MessageReceived(BMessage *message)
}
bool
DialUpView::SelectInterfaceNamed(const char *name)
{
BMenuItem *item = fInterfaceMenu->FindItem(name);
int32 index = fInterfaceMenu->IndexOf(item);
if(!item || index >= CountInterfaces())
return false;
SelectInterface(index);
return true;
}
bool
DialUpView::NeedsRequest() const
{
return fGeneralAddon ? fGeneralAddon->NeedsAuthenticationRequest() : false;
}
BView*
DialUpView::AuthenticationView() const
{
return fGeneralAddon ? fGeneralAddon->AuthenticationView() : NULL;
}
BView*
DialUpView::StatusView() const
{
return fStatusView;
}
BView*
DialUpView::ConnectButton() const
{
return fConnectButton;
}
bool
DialUpView::LoadSettings(bool isNew)
{
fSettings.MakeEmpty();
fProfile.MakeEmpty();
BMessage *settingsPointer = fCurrentItem ? &fSettings : NULL,
*profilePointer = fCurrentItem ? &fProfile : NULL;
if(fCurrentItem && !isNew) {
BString name("pppidf/");
name << fCurrentItem->Label();
if(!ReadMessageDriverSettings(name.String(), &fSettings))
return false;
name = "pppidf/profile/";
name << fCurrentItem->Label();
if(!ReadMessageDriverSettings(name.String(), &fProfile))
profilePointer = settingsPointer;
}
DialUpAddon *addon;
for(int32 index = 0; fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index,
reinterpret_cast<void**>(&addon)) == B_OK; index++) {
if(!addon)
continue;
if(!addon->LoadSettings(settingsPointer, profilePointer, isNew))
return false;
}
// TODO: check if settings are valid
return true;
}
void
DialUpView::IsModified(bool *settings, bool *profile)
{
*settings = *profile = false;
bool addonSettingsChanged, addonProfileChanged;
// for current addon
DialUpAddon *addon;
for(int32 index = 0; fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index,
reinterpret_cast<void**>(&addon)) == B_OK; index++) {
if(!addon)
continue;
addon->IsModified(&addonSettingsChanged, &addonProfileChanged);
if(addonSettingsChanged)
*settings = true;
if(addonProfileChanged)
*profile = true;
}
}
bool
DialUpView::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporary)
{
if(!fCurrentItem || !settings || !profile)
return false;
DialUpAddon *addon;
TemplateList<DialUpAddon*> addons;
for(int32 index = 0;
fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index,
reinterpret_cast<void**>(&addon)) == B_OK; index++) {
if(!addon)
continue;
int32 insertIndex = 0;
for(; insertIndex < addons.CountItems(); insertIndex++)
if(addons.ItemAt(insertIndex)->Priority() <= addon->Priority())
break;
addons.AddItem(addon, insertIndex);
}
settings->AddInt32("Interface", static_cast<int32>(fWatching));
if(fCurrentItem)
settings->AddString("InterfaceName", fCurrentItem->Label());
for(int32 index = 0; index < addons.CountItems(); index++)
if(!addons.ItemAt(index)->SaveSettings(settings, profile, saveTemporary))
return false;
return true;
}
bool
DialUpView::SaveSettingsToFile()
{
bool settingsChanged, profileChanged;
IsModified(&settingsChanged, &profileChanged);
if(!settingsChanged && !profileChanged)
return true;
BMessage settings, profile;
if(!SaveSettings(&settings, &profile, false))
return false;
BDirectory settingsDirectory;
BDirectory profileDirectory;
GetPPPDirectories(&settingsDirectory, &profileDirectory);
if(settingsDirectory.InitCheck() != B_OK || profileDirectory.InitCheck() != B_OK)
return false;
BFile file;
if(settingsChanged) {
settingsDirectory.CreateFile(fCurrentItem->Label(), &file);
WriteMessageDriverSettings(file, settings);
}
if(profileChanged) {
profileDirectory.CreateFile(fCurrentItem->Label(), &file);
WriteMessageDriverSettings(file, profile);
}
return true;
}
void
DialUpView::UpDownThread()
{
SaveSettingsToFile();
fSettings.SaveSettingsToFile();
BMessage settings, profile;
SaveSettings(&settings, &profile, true);
fSettings.SaveSettings(&settings, &profile, true);
// save temporary profile
driver_settings *temporaryProfile = MessageToDriverSettings(profile);
@@ -531,32 +331,6 @@ DialUpView::UpDownThread()
}
void
DialUpView::GetPPPDirectories(BDirectory *settingsDirectory,
BDirectory *profileDirectory) const
{
if(settingsDirectory) {
BDirectory settings(PPP_INTERFACE_SETTINGS_PATH);
if(settings.InitCheck() != B_OK) {
create_directory(PPP_INTERFACE_SETTINGS_PATH, 0750);
settings.SetTo(PPP_INTERFACE_SETTINGS_PATH);
}
*settingsDirectory = settings;
}
if(profileDirectory) {
BDirectory profile(PPP_INTERFACE_SETTINGS_PATH "/profile");
if(profile.InitCheck() != B_OK) {
create_directory(PPP_INTERFACE_SETTINGS_PATH "/profile", 0750);
profile.SetTo(PPP_INTERFACE_SETTINGS_PATH "/profile");
}
*profileDirectory = profile;
}
}
void
DialUpView::HandleReportMessage(BMessage *message)
{
@@ -612,7 +386,7 @@ DialUpView::CreateTabs()
TemplateList<DialUpAddon*> addons;
for(int32 index = 0;
fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index,
fSettings.Addons().FindPointer(DUN_TAB_ADDON_TYPE, index,
reinterpret_cast<void**>(&addon)) == B_OK;
index++) {
if(!addon || addon->Position() < 0)
@@ -763,7 +537,7 @@ DialUpView::LoadInterfaces()
BDirectory settingsDirectory;
BEntry entry;
BPath path;
GetPPPDirectories(&settingsDirectory, NULL);
fSettings.GetPTPDirectories(&settingsDirectory, NULL);
while(settingsDirectory.GetNextEntry(&entry) == B_OK) {
if(entry.IsFile()) {
entry.GetPath(&path);
@@ -774,47 +548,7 @@ DialUpView::LoadInterfaces()
void
DialUpView::LoadAddons()
{
// Load integrated add-ons:
// "Connection Options" tab
ConnectionOptionsAddon *connectionOptionsAddon =
new ConnectionOptionsAddon(&fAddons);
fAddons.AddPointer(DUN_TAB_ADDON_TYPE, connectionOptionsAddon);
fAddons.AddPointer(DUN_DELETE_ON_QUIT, connectionOptionsAddon);
// "General" tab
GeneralAddon *fGeneralAddon = new GeneralAddon(&fAddons);
fAddons.AddPointer(DUN_TAB_ADDON_TYPE, fGeneralAddon);
fAddons.AddPointer(DUN_DELETE_ON_QUIT, fGeneralAddon);
// "IPCP" protocol
IPCPAddon *ipcpAddon = new IPCPAddon(&fAddons);
fAddons.AddPointer(DUN_TAB_ADDON_TYPE, ipcpAddon);
fAddons.AddPointer(DUN_DELETE_ON_QUIT, ipcpAddon);
// "PPPoE" device
PPPoEAddon *pppoeAddon = new PPPoEAddon(&fAddons);
fAddons.AddPointer(DUN_DEVICE_ADDON_TYPE, pppoeAddon);
fAddons.AddPointer(DUN_DELETE_ON_QUIT, pppoeAddon);
// "PAP" authenticator
BMessage addon;
#ifdef LANG_GERMAN
addon.AddString("FriendlyName", "Unverschlüsselt");
#else
addon.AddString("FriendlyName", "Plain-text Authentication");
#endif
addon.AddString("TechnicalName", "PAP");
addon.AddString("KernelModuleName", "pap");
fAddons.AddMessage(DUN_AUTHENTICATOR_ADDON_TYPE, &addon);
// addon.MakeEmpty(); // for next authenticator
// TODO:
// load all add-ons from the add-ons folder
}
void
DialUpView::AddInterface(const char *name, bool isNew)
DialUpView::AddInterface(const char *name, bool isNew = false)
{
if(fInterfaceMenu->FindItem(name)) {
(new BAlert(kErrorTitle, kErrorInterfaceExists, kLabelOK,
@@ -836,13 +570,13 @@ DialUpView::AddInterface(const char *name, bool isNew)
void
DialUpView::SelectInterface(int32 index, bool isNew)
DialUpView::SelectInterface(int32 index, bool isNew = false)
{
BMenuItem *item = fInterfaceMenu->FindMarked();
if(fCurrentItem && item == fCurrentItem)
return;
if(fCurrentItem && !SaveSettingsToFile())
if(fCurrentItem && !fSettings.SaveSettingsToFile())
(new BAlert(kErrorTitle, kErrorSavingFailed, kLabelOK,
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(NULL);
@@ -866,13 +600,13 @@ DialUpView::SelectInterface(int32 index, bool isNew)
}
if(!fCurrentItem)
LoadSettings(false);
fSettings.LoadSettings(NULL, false);
// tell modules to unload all settings
else if(!isNew && !LoadSettings(false)) {
else if(!isNew && !fSettings.LoadSettings(fCurrentItem->Label(), false)) {
(new BAlert(kErrorTitle, kErrorLoadingFailed, kLabelOK,
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(NULL);
LoadSettings(true);
} else if(isNew && !LoadSettings(true))
fSettings.LoadSettings(fCurrentItem->Label(), true);
} else if(isNew && !fSettings.LoadSettings(fCurrentItem->Label(), true))
(new BAlert(kErrorTitle, kErrorLoadingFailed, kLabelOK,
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(NULL);
}
+6 -39
View File
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
* Distributed under the terms of the MIT License.
*/
#ifndef _DIAL_UP_VIEW__H
#define _DIAL_UP_VIEW__H
@@ -27,8 +10,7 @@
#include <View.h>
#include <PPPInterfaceListener.h>
class GeneralAddon;
#include <PTPSettings.h>
class DialUpView : public BView {
@@ -40,15 +22,6 @@ class DialUpView : public BView {
virtual void MessageReceived(BMessage *message);
void UpDownThread();
// used by ppp_up application
bool SelectInterfaceNamed(const char *name);
bool NeedsRequest() const;
BView *AuthenticationView() const;
BView *StatusView() const;
BView *ConnectButton() const;
bool SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporary);
bool SaveSettingsToFile();
private:
void GetPPPDirectories(BDirectory *settingsDirectory,
@@ -60,11 +33,7 @@ class DialUpView : public BView {
void UpdateStatus(int32 code);
void WatchInterface(ppp_interface_id ID);
bool LoadSettings(bool isNew);
void IsModified(bool *settings, bool *profile);
void LoadInterfaces();
void LoadAddons();
void AddInterface(const char *name, bool isNew = false);
void SelectInterface(int32 index, bool isNew = false);
@@ -74,15 +43,13 @@ class DialUpView : public BView {
private:
PPPInterfaceListener fListener;
PTPSettings fSettings;
thread_id fUpDownThread;
BMessage fAddons, fSettings, fProfile;
driver_settings *fDriverSettings;
BMenuItem *fCurrentItem, *fDeleterItem;
ppp_interface_id fWatching;
GeneralAddon *fGeneralAddon;
bool fKeepLabel;
BStringView *fStatusView;
BButton *fConnectButton, *fCreateNewButton;
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// GeneralAddon saves the loaded settings.
@@ -81,6 +64,7 @@ static const char *kGeneralTabAuthenticators = "Authenticators";
GeneralAddon::GeneralAddon(BMessage *addons)
: DialUpAddon(addons),
fHasPassword(false),
fDeleteView(false),
fAuthenticatorsCount(0),
fSettings(NULL),
fProfile(NULL),
@@ -91,13 +75,8 @@ GeneralAddon::GeneralAddon(BMessage *addons)
GeneralAddon::~GeneralAddon()
{
}
bool
GeneralAddon::NeedsAuthenticationRequest() const
{
return fGeneralView->AuthenticatorName();
if(fDeleteView)
delete fGeneralView;
}
@@ -125,9 +104,13 @@ GeneralAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
fSettings = settings;
fProfile = profile;
if(fGeneralView)
fGeneralView->Reload();
// reset all views (empty settings)
if(!fGeneralView) {
CreateView(BPoint(0,0));
fDeleteView = true;
}
fGeneralView->Reload();
// reset all views (empty settings)
if(!settings || !profile || isNew)
return true;
@@ -138,9 +121,8 @@ GeneralAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
if(!LoadAuthenticationSettings())
return false;
if(fGeneralView)
fGeneralView->Reload();
// reload new settings
fGeneralView->Reload();
// reload new settings
return true;
}
@@ -351,21 +333,16 @@ GeneralAddon::CreateView(BPoint leftTop)
BRect rect;
Addons()->FindRect(DUN_TAB_VIEW_RECT, &rect);
fGeneralView = new GeneralView(this, rect);
fGeneralView->Reload();
}
fDeleteView = false;
fGeneralView->MoveTo(leftTop);
fGeneralView->Reload();
return fGeneralView;
}
BView*
GeneralAddon::AuthenticationView() const
{
return fGeneralView ? fGeneralView->AuthenticationView() : NULL;
}
bool
GeneralAddon::GetAuthenticator(const BString& moduleName, BMessage *entry) const
{
@@ -439,12 +416,10 @@ GeneralView::GeneralView(GeneralAddon *addon, BRect frame)
rect = fAuthenticationBox->Bounds();
rect.InsetBy(10, 5);
rect.top = 25;
// fAuthenticationView = new BControl(rect, "authenticationView", NULL, NULL,
// B_FOLLOW_NONE, 0);
// BControl automatically sets the view color when attached (we want that)
fAuthenticationView = new BView(rect, "authenticationView", B_FOLLOW_NONE, 0);
fAuthenticationView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
rect = fAuthenticationView->Bounds();
BView *authenticationView = new BView(rect, "authenticationView",
B_FOLLOW_NONE, 0);
authenticationView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
rect = authenticationView->Bounds();
rect.bottom = rect.top + 20;
fUsername = new BTextControl(rect, "username", kLabelName, NULL, NULL);
rect.top = rect.bottom + 5;
@@ -462,10 +437,10 @@ GeneralView::GeneralView(GeneralAddon *addon, BRect frame)
rect.bottom = rect.top + 20;
fSavePassword = new BCheckBox(rect, "SavePassword", kLabelSavePassword, NULL);
fAuthenticationView->AddChild(fUsername);
fAuthenticationView->AddChild(fPassword);
fAuthenticationView->AddChild(fSavePassword);
fAuthenticationBox->AddChild(fAuthenticationView);
authenticationView->AddChild(fUsername);
authenticationView->AddChild(fPassword);
authenticationView->AddChild(fSavePassword);
fAuthenticationBox->AddChild(authenticationView);
AddChild(fDeviceBox);
AddChild(fAuthenticationBox);
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// GeneralAddon saves the loaded settings.
@@ -54,8 +37,6 @@ class GeneralAddon : public DialUpAddon {
bool HasPassword() const
{ return fHasPassword; }
bool NeedsAuthenticationRequest() const;
DialUpAddon *FindDevice(const BString& moduleName) const;
DialUpAddon *DeviceAddon() const
{ return fDeviceAddon; }
@@ -83,16 +64,13 @@ class GeneralAddon : public DialUpAddon {
bool saveTemporary);
virtual bool GetPreferredSize(float *width, float *height) const;
virtual BView *CreateView(BPoint leftTop);
// used by ppp_up application
BView *AuthenticationView() const;
private:
bool GetAuthenticator(const BString& moduleName, BMessage *entry) const;
bool MarkAuthenticatorAsValid(const BString& moduleName);
private:
bool fIsNew, fHasPassword;
bool fIsNew, fHasPassword, fDeleteView;
BString fDeviceName, fUsername, fPassword;
DialUpAddon *fDeviceAddon;
int32 fAuthenticatorsCount;
@@ -130,10 +108,6 @@ class GeneralView : public BView {
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *message);
// used by ppp_up application
BView *AuthenticationView() const
{ return fAuthenticationView; }
private:
void ReloadDeviceView();
@@ -146,7 +120,6 @@ class GeneralView : public BView {
GeneralAddon *fAddon;
DialUpAddon *fDeviceAddon;
BBox *fDeviceBox, *fAuthenticationBox;
BView *fAuthenticationView;
BMenuField *fDeviceField, *fAuthenticatorField;
BMenuItem *fAuthenticatorNone, *fAuthenticatorDefault;
BTextControl *fUsername, *fPassword;
+16 -28
View File
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// IPCPAddon saves the loaded settings.
@@ -70,13 +53,18 @@ static const char *kKernelModuleName = "ipcp";
IPCPAddon::IPCPAddon(BMessage *addons)
: DialUpAddon(addons),
fSettings(NULL),
fProfile(NULL)
fProfile(NULL),
fIPCPView(NULL)
{
CreateView(BPoint(0,0));
fDeleteView = true;
}
IPCPAddon::~IPCPAddon()
{
if(fDeleteView)
delete fIPCPView;
}
@@ -89,9 +77,8 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
fSettings = settings;
fProfile = profile;
if(fIPCPView)
fIPCPView->Reload();
// reset all views (empty settings)
fIPCPView->Reload();
// reset all views (empty settings)
if(!settings || !profile || isNew)
return true;
@@ -164,8 +151,7 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
protocol.AddBool(MDSU_VALID, true);
fProfile->ReplaceMessage(MDSU_PARAMETERS, protocolIndex, &protocol);
if(fIPCPView)
fIPCPView->Reload();
fIPCPView->Reload();
return true;
}
@@ -265,10 +251,12 @@ IPCPAddon::CreateView(BPoint leftTop)
BRect rect;
Addons()->FindRect(DUN_TAB_VIEW_RECT, &rect);
fIPCPView = new IPCPView(this, rect);
fIPCPView->Reload();
}
fDeleteView = false;
fIPCPView->MoveTo(leftTop);
fIPCPView->Reload();
return fIPCPView;
}
+5 -22
View File
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// IPCPAddon saves the loaded settings.
@@ -73,7 +56,7 @@ class IPCPAddon : public DialUpAddon {
int32 FindIPCPProtocol(const BMessage& message, BMessage *protocol) const;
private:
bool fIsNew, fIsEnabled;
bool fIsNew, fIsEnabled, fDeleteView;
BString fIPAddress, fPrimaryDNS, fSecondaryDNS;
BMessage *fSettings, *fProfile;
// saves last settings state
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
#include "InterfaceUtils.h"
@@ -28,12 +11,13 @@
#include <MenuItem.h>
#include <Screen.h>
#include <String.h>
#include <ListItem.h> // Contains StringItem class declaration
#include <ListItem.h>
// contains StringItem class declaration
#include <Window.h>
BPoint
center_on_screen(BRect rect, BWindow *window)
center_on_screen(BRect rect, BWindow *window = NULL)
{
BRect screenFrame = (BScreen(window).Frame());
BPoint point((screenFrame.Width() - rect.Width()) / 2.0,
@@ -46,7 +30,7 @@ center_on_screen(BRect rect, BWindow *window)
int32
FindNextMenuInsertionIndex(BMenu *menu, const char *name, int32 index)
FindNextMenuInsertionIndex(BMenu *menu, const char *name, int32 index = 0)
{
BMenuItem *item;
for(; index < menu->CountItems(); index++) {
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _INTERFACE_UTILS__H
#define _INTERFACE_UTILS__H
+5 -4
View File
@@ -23,10 +23,10 @@ UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp ipcp ] ; # IPCP
AddResources DialUpPreflet : DialUpPreflet.rdef ;
StaticLibrary dunview :
DialUpView.cpp
StaticLibrary ptpnet :
PTPSettings.cpp
# utils
# utils (TODO: move into their own library)
InterfaceUtils.cpp
MessageDriverSettingsUtils.cpp
TextRequestDialog.cpp
@@ -40,6 +40,7 @@ StaticLibrary dunview :
SimpleTest DialUpPreflet :
DialUpApplication.cpp
DialUpView.cpp
;
LinkSharedOSLibs DialUpPreflet : libdunview.a libppp.a be ;
LinkSharedOSLibs DialUpPreflet : libptpnet.a libppp.a be ;
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
#include "MessageDriverSettingsUtils.h"
@@ -36,7 +19,7 @@ static bool AddParameters(const BMessage& message, driver_settings *to);
bool
FindMessageParameter(const char *name, const BMessage& message, BMessage *save,
int32 *startIndex)
int32 *startIndex = NULL)
{
// XXX: this should be removed when we can replace BMessage with something better
BString string;
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _MESSAGE_DRIVER_SETTINGS_UTILS__H
#define _MESSAGE_DRIVER_SETTINGS_UTILS__H
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// PPPoEAddon saves the loaded settings.
@@ -96,13 +79,13 @@ PPPoEAddon::PPPoEAddon(BMessage *addons)
fHeight = 20 // interface name control
+ 20 // service control
+ 5 + 2; // space between controls and bottom
CreateView(BPoint(0,0));
}
PPPoEAddon::~PPPoEAddon()
{
delete fPPPoEView;
// this may have been set to NULL from the view's destructor!
}
@@ -135,8 +118,7 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
fSettings = settings;
fProfile = profile;
if(fPPPoEView)
fPPPoEView->Reload();
fPPPoEView->Reload();
if(!settings || !profile || isNew)
return true;
@@ -175,8 +157,7 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
device.AddBool(MDSU_VALID, true);
fSettings->ReplaceMessage(MDSU_PARAMETERS, deviceIndex, &device);
if(fPPPoEView)
fPPPoEView->Reload();
fPPPoEView->Reload();
return true;
}
@@ -249,16 +230,16 @@ PPPoEAddon::CreateView(BPoint leftTop)
{
if(!fPPPoEView) {
float width;
if(!Addons()->FindFloat(DUN_DEVICE_VIEW_WIDTH, &width))
if(Addons()->FindFloat(DUN_DEVICE_VIEW_WIDTH, &width) != B_OK)
width = 270;
// default value
BRect rect(0, 0, width, fHeight);
fPPPoEView = new PPPoEView(this, rect);
fPPPoEView->Reload();
}
fPPPoEView->MoveTo(leftTop);
fPPPoEView->Reload();
return fPPPoEView;
}
+4 -21
View File
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
//-----------------------------------------------------------------------
// PPPoEAddon saves the loaded settings.
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
#include "TextRequestDialog.h"
#include "InterfaceUtils.h"
@@ -44,7 +27,7 @@ static const char *kLabelCancel = "Cancel";
TextRequestDialog::TextRequestDialog(const char *title, const char *information,
const char *request, const char *text)
const char *request, const char *text = NULL)
: BWindow(kWindowRect, title, B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE, 0),
fInvoker(NULL)
{
@@ -1,24 +1,7 @@
/* -----------------------------------------------------------------------
* Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ----------------------------------------------------------------------- */
/*
* Copyright 2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _TEXT_REQUEST_DIALOG__H
#define _TEXT_REQUEST_DIALOG__H