diff --git a/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp b/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp index 4cab6915e5..72b078feef 100644 --- a/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp @@ -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 + * 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, ¶meter); } - 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; } diff --git a/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.h b/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.h index 9c263c602b..63f0bbd5d4 100644 --- a/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.h +++ b/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.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 + * 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 diff --git a/src/tests/kits/net/DialUpPreflet/DialUpAddon.h b/src/tests/kits/net/DialUpPreflet/DialUpAddon.h index a9aa2d5a88..fcd3d3dbd8 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpAddon.h +++ b/src/tests/kits/net/DialUpPreflet/DialUpAddon.h @@ -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 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ /*! \class DialUpAddon \brief Base class for DialUpPreflet add-ons. diff --git a/src/tests/kits/net/DialUpPreflet/DialUpApplication.cpp b/src/tests/kits/net/DialUpPreflet/DialUpApplication.cpp index 376dd6cfce..fd28ee5b09 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpApplication.cpp +++ b/src/tests/kits/net/DialUpPreflet/DialUpApplication.cpp @@ -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 + * Distributed under the terms of the MIT License. + */ #include #include diff --git a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp index a4492757b0..effe14dca9 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp +++ b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp @@ -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 + * 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 #include #include @@ -51,7 +28,6 @@ #include #include -#include #include @@ -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(&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(&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(&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 addons; - for(int32 index = 0; - fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index, - reinterpret_cast(&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(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 addons; for(int32 index = 0; - fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index, + fSettings.Addons().FindPointer(DUN_TAB_ADDON_TYPE, index, reinterpret_cast(&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); } diff --git a/src/tests/kits/net/DialUpPreflet/DialUpView.h b/src/tests/kits/net/DialUpPreflet/DialUpView.h index b3399da14d..890d80e2d8 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpView.h +++ b/src/tests/kits/net/DialUpPreflet/DialUpView.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 + * Distributed under the terms of the MIT License. + */ #ifndef _DIAL_UP_VIEW__H #define _DIAL_UP_VIEW__H @@ -27,8 +10,7 @@ #include #include - -class GeneralAddon; +#include 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; diff --git a/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp b/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp index 5879ab5700..ef1e677d0e 100644 --- a/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp @@ -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 + * 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); diff --git a/src/tests/kits/net/DialUpPreflet/GeneralAddon.h b/src/tests/kits/net/DialUpPreflet/GeneralAddon.h index cbb2b96aa1..bb6160f4b9 100644 --- a/src/tests/kits/net/DialUpPreflet/GeneralAddon.h +++ b/src/tests/kits/net/DialUpPreflet/GeneralAddon.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 + * 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; diff --git a/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp b/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp index 606bcfe741..e88954ceb1 100644 --- a/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp @@ -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 + * 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; } diff --git a/src/tests/kits/net/DialUpPreflet/IPCPAddon.h b/src/tests/kits/net/DialUpPreflet/IPCPAddon.h index 11d754e8e0..40d36c92a7 100644 --- a/src/tests/kits/net/DialUpPreflet/IPCPAddon.h +++ b/src/tests/kits/net/DialUpPreflet/IPCPAddon.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 + * 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 diff --git a/src/tests/kits/net/DialUpPreflet/InterfaceUtils.cpp b/src/tests/kits/net/DialUpPreflet/InterfaceUtils.cpp index 03743ecca7..59d57f89b1 100644 --- a/src/tests/kits/net/DialUpPreflet/InterfaceUtils.cpp +++ b/src/tests/kits/net/DialUpPreflet/InterfaceUtils.cpp @@ -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 + * Distributed under the terms of the MIT License. + */ #include "InterfaceUtils.h" @@ -28,12 +11,13 @@ #include #include #include -#include // Contains StringItem class declaration +#include + // contains StringItem class declaration #include 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++) { diff --git a/src/tests/kits/net/DialUpPreflet/InterfaceUtils.h b/src/tests/kits/net/DialUpPreflet/InterfaceUtils.h index dd8626c674..e3419e8612 100644 --- a/src/tests/kits/net/DialUpPreflet/InterfaceUtils.h +++ b/src/tests/kits/net/DialUpPreflet/InterfaceUtils.h @@ -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 + * Distributed under the terms of the MIT License. + */ #ifndef _INTERFACE_UTILS__H #define _INTERFACE_UTILS__H diff --git a/src/tests/kits/net/DialUpPreflet/Jamfile b/src/tests/kits/net/DialUpPreflet/Jamfile index e3e77d7b60..e060992e4c 100644 --- a/src/tests/kits/net/DialUpPreflet/Jamfile +++ b/src/tests/kits/net/DialUpPreflet/Jamfile @@ -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 ; diff --git a/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp b/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp index 4a27ba0739..576f7eeb21 100644 --- a/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp +++ b/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp @@ -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 + * 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; diff --git a/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.h b/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.h index 40ab975922..8bc49d446b 100644 --- a/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.h +++ b/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.h @@ -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 + * Distributed under the terms of the MIT License. + */ #ifndef _MESSAGE_DRIVER_SETTINGS_UTILS__H #define _MESSAGE_DRIVER_SETTINGS_UTILS__H diff --git a/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp b/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp index 850b656334..c87e46c38a 100644 --- a/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp @@ -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 + * 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; } diff --git a/src/tests/kits/net/DialUpPreflet/PPPoEAddon.h b/src/tests/kits/net/DialUpPreflet/PPPoEAddon.h index a969370b18..a8206be08f 100644 --- a/src/tests/kits/net/DialUpPreflet/PPPoEAddon.h +++ b/src/tests/kits/net/DialUpPreflet/PPPoEAddon.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 + * Distributed under the terms of the MIT License. + */ //----------------------------------------------------------------------- // PPPoEAddon saves the loaded settings. diff --git a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp index 514e7bc8c9..e4ed610348 100644 --- a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp +++ b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp @@ -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 + * 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) { diff --git a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h index 0f9f1677ef..d094837ca3 100644 --- a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h +++ b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h @@ -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 + * Distributed under the terms of the MIT License. + */ #ifndef _TEXT_REQUEST_DIALOG__H #define _TEXT_REQUEST_DIALOG__H