network_settings/dialup: Update copyright headers.
Also reformat the rdef to match the other network_settings.
This commit is contained in:
parent
922badcfe1
commit
adae1a12b8
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright 2003-2004 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// ConnectionOptionsAddon saves the loaded settings.
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// ConnectionOptionsAddon saves the loaded settings.
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*! \class DialUpAddon
|
||||
\brief Base class for DialUpPreflet add-ons.
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
@ -40,7 +24,7 @@ class DialUpApplication : public BApplication {
|
||||
class DialUpWindow : public BWindow {
|
||||
public:
|
||||
DialUpWindow(BRect frame);
|
||||
|
||||
|
||||
virtual bool QuitRequested()
|
||||
{ be_app->PostMessage(B_QUIT_REQUESTED); return true; }
|
||||
};
|
||||
@ -49,11 +33,11 @@ class DialUpWindow : public BWindow {
|
||||
int main()
|
||||
{
|
||||
new DialUpApplication();
|
||||
|
||||
|
||||
be_app->Run();
|
||||
|
||||
|
||||
delete be_app;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -72,6 +56,6 @@ DialUpWindow::DialUpWindow(BRect frame)
|
||||
: BWindow(frame, "DialUp", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
DialUpView *view = new DialUpView(Bounds());
|
||||
|
||||
|
||||
AddChild(view);
|
||||
}
|
||||
|
@ -1,37 +1,11 @@
|
||||
/*
|
||||
DialUpPreflet.rdef
|
||||
*/
|
||||
|
||||
resource app_signature "application/x-vnd.haiku.dial-up-preflet";
|
||||
|
||||
/* BEOS:APP_FLAGS :
|
||||
00000000 = SINGLE LAUNCH
|
||||
00000001 = MULTIPLE LAUNCH
|
||||
00000002 = EXCLUSIVE LAUNCH
|
||||
00000004 = BACKGROUND APP + SINGLE LAUNCH
|
||||
00000005 = BACKGROUND APP + MULTIPLE LAUNCH
|
||||
00000006 = BACKGROUND APP + EXCLUSIVE LAUNCH
|
||||
00000008 = ARGV_ONLY + SINGLE LAUNCH
|
||||
00000009 = ARGV_ONLY + MULTIPLE LAUNCH
|
||||
0000000A = ARGV_ONLY + EXCLUSIVE LAUNCH
|
||||
0000000C = ARGV_ONLY + BACKGROUND APP + SINGLE LAUNCH
|
||||
0000000D = ARGV_ONLY + BACKGROUND APP + MULTIPLE LAUNCH
|
||||
0000000E = ARGV_ONLY + BACKGROUND APP + EXCLUSIVE LAUNCH
|
||||
*/
|
||||
|
||||
resource app_flags 0x00000000;
|
||||
resource app_signature "application/x-vnd.Haiku-DialUpInterface";
|
||||
|
||||
resource app_version {
|
||||
major = 0,
|
||||
middle = 1,
|
||||
major = 1,
|
||||
middle = 0,
|
||||
minor = 0,
|
||||
|
||||
/* 0 = development 1 = alpha 2 = beta
|
||||
3 = gamma 4 = golden master 5 = final */
|
||||
variety = 0,
|
||||
|
||||
internal = 0,
|
||||
|
||||
short_info = "DialUpPreflet",
|
||||
short_info = "DialUpInterface",
|
||||
long_info = "PPP interface configuration tool."
|
||||
};
|
||||
|
@ -1,24 +1,9 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "DialUpView.h"
|
||||
#include "DialUpAddon.h"
|
||||
|
@ -1,25 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DIAL_UP_VIEW__H
|
||||
#define _DIAL_UP_VIEW__H
|
||||
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// GeneralAddon saves the loaded settings.
|
||||
@ -97,7 +81,7 @@ GeneralAddon::FindDevice(const BString& moduleName) const
|
||||
reinterpret_cast<void**>(&addon)) == B_OK; index++)
|
||||
if(addon && moduleName == addon->KernelModuleName())
|
||||
return addon;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -112,24 +96,24 @@ GeneralAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
fAuthenticatorsCount = 0;
|
||||
fSettings = settings;
|
||||
fProfile = profile;
|
||||
|
||||
|
||||
if(fGeneralView)
|
||||
fGeneralView->Reload();
|
||||
// reset all views (empty settings)
|
||||
|
||||
|
||||
if(!settings || !profile || isNew)
|
||||
return true;
|
||||
|
||||
|
||||
if(!LoadDeviceSettings())
|
||||
return false;
|
||||
|
||||
|
||||
if(!LoadAuthenticationSettings())
|
||||
return false;
|
||||
|
||||
|
||||
if(fGeneralView)
|
||||
fGeneralView->Reload();
|
||||
// reload new settings
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -142,18 +126,18 @@ GeneralAddon::LoadDeviceSettings()
|
||||
if(!FindMessageParameter(PPP_DEVICE_KEY, *fSettings, &device, &index))
|
||||
return false;
|
||||
// TODO: tell user that device specification is missing
|
||||
|
||||
|
||||
if(device.FindString(MDSU_VALUES, &fDeviceName) != B_OK)
|
||||
return false;
|
||||
// TODO: tell user that device specification is missing
|
||||
|
||||
|
||||
device.AddBool(MDSU_VALID, true);
|
||||
fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &device);
|
||||
|
||||
|
||||
fDeviceAddon = FindDevice(fDeviceName);
|
||||
if(!fDeviceAddon)
|
||||
return false;
|
||||
|
||||
|
||||
return fDeviceAddon->LoadSettings(fSettings, fProfile, false);
|
||||
}
|
||||
|
||||
@ -164,10 +148,10 @@ GeneralAddon::LoadAuthenticationSettings()
|
||||
// we only handle the profile (although settings could contain different data)
|
||||
int32 itemIndex = 0;
|
||||
BMessage authentication, item;
|
||||
|
||||
|
||||
if(!FindMessageParameter(PPP_AUTHENTICATOR_KEY, *fProfile, &item, &itemIndex))
|
||||
return true;
|
||||
|
||||
|
||||
// find authenticators (though we load all authenticators, we only use one)
|
||||
BString name;
|
||||
for(int32 index = 0; item.FindString(MDSU_VALUES, index, &name) == B_OK; index++) {
|
||||
@ -175,17 +159,17 @@ GeneralAddon::LoadAuthenticationSettings()
|
||||
if(!GetAuthenticator(name, &authenticator))
|
||||
return false;
|
||||
// fatal error: we do not know how to handle this authenticator
|
||||
|
||||
|
||||
MarkAuthenticatorAsValid(name);
|
||||
authentication.AddString(kGeneralTabAuthenticators, name);
|
||||
++fAuthenticatorsCount;
|
||||
}
|
||||
|
||||
|
||||
fSettings->AddMessage(kGeneralTabAuthentication, &authentication);
|
||||
|
||||
|
||||
bool hasUsername = false;
|
||||
// a username must be present
|
||||
|
||||
|
||||
// load username and password
|
||||
BMessage parameter;
|
||||
int32 parameterIndex = 0;
|
||||
@ -195,7 +179,7 @@ GeneralAddon::LoadAuthenticationSettings()
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
item.ReplaceMessage(MDSU_PARAMETERS, parameterIndex, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
parameterIndex = 0;
|
||||
if(FindMessageParameter("Password", item, ¶meter, ¶meterIndex)
|
||||
&& parameter.FindString(MDSU_VALUES, &fPassword) == B_OK) {
|
||||
@ -203,13 +187,13 @@ GeneralAddon::LoadAuthenticationSettings()
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
item.ReplaceMessage(MDSU_PARAMETERS, parameterIndex, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
// tell DUN whether everything is valid
|
||||
if(hasUsername)
|
||||
item.AddBool(MDSU_VALID, true);
|
||||
|
||||
|
||||
fProfile->ReplaceMessage(MDSU_PARAMETERS, itemIndex, &item);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -228,12 +212,12 @@ GeneralAddon::IsModified(bool *settings, bool *profile) const
|
||||
*settings = *profile = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool deviceSettings, authenticationSettings, deviceProfile, authenticationProfile;
|
||||
|
||||
|
||||
IsDeviceModified(&deviceSettings, &deviceProfile);
|
||||
IsAuthenticationModified(&authenticationSettings, &authenticationProfile);
|
||||
|
||||
|
||||
*settings = (deviceSettings || authenticationSettings);
|
||||
*profile = (deviceProfile || authenticationProfile);
|
||||
}
|
||||
@ -259,7 +243,7 @@ GeneralAddon::IsAuthenticationModified(bool *settings, bool *profile) const
|
||||
return;
|
||||
// error!
|
||||
}
|
||||
|
||||
|
||||
BString authenticator;
|
||||
if(authentication.FindString(kGeneralTabAuthenticators,
|
||||
&authenticator) != B_OK) {
|
||||
@ -267,11 +251,11 @@ GeneralAddon::IsAuthenticationModified(bool *settings, bool *profile) const
|
||||
return;
|
||||
// error!
|
||||
}
|
||||
|
||||
|
||||
*settings = (!fGeneralView->AuthenticatorName()
|
||||
|| authenticator != fGeneralView->AuthenticatorName());
|
||||
}
|
||||
|
||||
|
||||
*profile = (*settings || fUsername != fGeneralView->Username()
|
||||
|| (fPassword != fGeneralView->Password() && fHasPassword)
|
||||
|| fHasPassword != fGeneralView->DoesSavePassword());
|
||||
@ -284,22 +268,22 @@ GeneralAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTempo
|
||||
if(!fSettings || !settings || !fGeneralView->DeviceName())
|
||||
return false;
|
||||
// TODO: tell user that a device is needed (if we fail because of this)
|
||||
|
||||
|
||||
if(!fGeneralView->DeviceAddon() || !fGeneralView->DeviceAddon()->SaveSettings(
|
||||
settings, profile, saveTemporary))
|
||||
return false;
|
||||
|
||||
|
||||
if(fGeneralView->AuthenticatorName()) {
|
||||
BMessage authenticator;
|
||||
authenticator.AddString(MDSU_NAME, PPP_AUTHENTICATOR_KEY);
|
||||
authenticator.AddString(MDSU_VALUES, fGeneralView->AuthenticatorName());
|
||||
settings->AddMessage(MDSU_PARAMETERS, &authenticator);
|
||||
|
||||
|
||||
BMessage username;
|
||||
username.AddString(MDSU_NAME, "User");
|
||||
username.AddString(MDSU_VALUES, fGeneralView->Username());
|
||||
authenticator.AddMessage(MDSU_PARAMETERS, &username);
|
||||
|
||||
|
||||
if(saveTemporary || fGeneralView->DoesSavePassword()) {
|
||||
// save password, too
|
||||
BMessage password;
|
||||
@ -307,10 +291,10 @@ GeneralAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTempo
|
||||
password.AddString(MDSU_VALUES, fGeneralView->Password());
|
||||
authenticator.AddMessage(MDSU_PARAMETERS, &password);
|
||||
}
|
||||
|
||||
|
||||
profile->AddMessage(MDSU_PARAMETERS, &authenticator);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -322,12 +306,12 @@ GeneralAddon::GetPreferredSize(float *width, float *height) const
|
||||
if(Addons()->FindRect(DUN_TAB_VIEW_RECT, &rect) != B_OK)
|
||||
rect.Set(0, 0, 200, 300);
|
||||
// set default values
|
||||
|
||||
|
||||
if(width)
|
||||
*width = rect.Width();
|
||||
if(height)
|
||||
*height = rect.Height();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -341,7 +325,7 @@ GeneralAddon::CreateView(BPoint leftTop)
|
||||
fGeneralView = new GeneralView(this, rect);
|
||||
fGeneralView->Reload();
|
||||
}
|
||||
|
||||
|
||||
fGeneralView->MoveTo(leftTop);
|
||||
return fGeneralView;
|
||||
}
|
||||
@ -359,7 +343,7 @@ GeneralAddon::GetAuthenticator(const BString& moduleName, BMessage *entry) const
|
||||
{
|
||||
if(!entry)
|
||||
return false;
|
||||
|
||||
|
||||
BString name;
|
||||
for(int32 index = 0; Addons()->FindMessage(DUN_AUTHENTICATOR_ADDON_TYPE, index,
|
||||
entry) == B_OK; index++) {
|
||||
@ -367,7 +351,7 @@ GeneralAddon::GetAuthenticator(const BString& moduleName, BMessage *entry) const
|
||||
if(name == moduleName)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -378,7 +362,7 @@ GeneralAddon::MarkAuthenticatorAsValid(const BString& moduleName)
|
||||
BMessage authenticator;
|
||||
int32 index = 0;
|
||||
BString name;
|
||||
|
||||
|
||||
for(; FindMessageParameter(PPP_AUTHENTICATOR_KEY, *fSettings, &authenticator,
|
||||
&index); index++) {
|
||||
authenticator.FindString("KernelModuleName", &name);
|
||||
@ -388,7 +372,7 @@ GeneralAddon::MarkAuthenticatorAsValid(const BString& moduleName)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -409,21 +393,21 @@ GeneralView::GeneralView(GeneralAddon *addon, BRect frame)
|
||||
+ 3 * 20 // size of controls
|
||||
+ 3 * 5; // space beween controls and bottom of box
|
||||
fAuthenticationBox = new BBox(rect, "Authentication");
|
||||
|
||||
|
||||
fDeviceField = new BMenuField(BRect(5, 0, 250, 20), "Device",
|
||||
kLabelDevice, new BPopUpMenu(kLabelNoDevicesFound));
|
||||
fDeviceField->SetDivider(StringWidth(fDeviceField->Label()) + 5);
|
||||
fDeviceField->Menu()->SetRadioMode(true);
|
||||
AddDevices();
|
||||
fDeviceBox->SetLabel(fDeviceField);
|
||||
|
||||
|
||||
fAuthenticatorField = new BMenuField(BRect(5, 0, 250, 20), "Authenticator",
|
||||
kLabelAuthenticator, new BPopUpMenu(kLabelNoAuthenticatorsFound));
|
||||
fAuthenticatorField->SetDivider(StringWidth(fAuthenticatorField->Label()) + 5);
|
||||
fAuthenticatorField->Menu()->SetRadioMode(true);
|
||||
AddAuthenticators();
|
||||
fAuthenticationBox->SetLabel(fAuthenticatorField);
|
||||
|
||||
|
||||
rect = fAuthenticationBox->Bounds();
|
||||
rect.InsetBy(10, 5);
|
||||
rect.top = 25;
|
||||
@ -439,22 +423,22 @@ GeneralView::GeneralView(GeneralAddon *addon, BRect frame)
|
||||
rect.bottom = rect.top + 20;
|
||||
fPassword = new BTextControl(rect, "password", kLabelPassword, NULL, NULL);
|
||||
fPassword->TextView()->HideTyping(true);
|
||||
|
||||
|
||||
// set dividers
|
||||
float width = max(StringWidth(fUsername->Label()),
|
||||
StringWidth(fPassword->Label()));
|
||||
fUsername->SetDivider(width + 5);
|
||||
fPassword->SetDivider(width + 5);
|
||||
|
||||
|
||||
rect.top = rect.bottom + 5;
|
||||
rect.bottom = rect.top + 20;
|
||||
fSavePassword = new BCheckBox(rect, "SavePassword", kLabelSavePassword, NULL);
|
||||
|
||||
|
||||
fAuthenticationView->AddChild(fUsername);
|
||||
fAuthenticationView->AddChild(fPassword);
|
||||
fAuthenticationView->AddChild(fSavePassword);
|
||||
fAuthenticationBox->AddChild(fAuthenticationView);
|
||||
|
||||
|
||||
AddChild(fDeviceBox);
|
||||
AddChild(fAuthenticationBox);
|
||||
}
|
||||
@ -469,7 +453,7 @@ void
|
||||
GeneralView::Reload()
|
||||
{
|
||||
fDeviceAddon = NULL;
|
||||
|
||||
|
||||
BMenuItem *item = NULL;
|
||||
for(int32 index = 0; index < fDeviceField->Menu()->CountItems(); index++) {
|
||||
item = fDeviceField->Menu()->ItemAt(index);
|
||||
@ -478,7 +462,7 @@ GeneralView::Reload()
|
||||
&& fDeviceAddon == Addon()->DeviceAddon())
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(fDeviceAddon && fDeviceAddon == Addon()->DeviceAddon())
|
||||
item->SetMarked(true);
|
||||
else if(Addon()->IsNew() && fDeviceField->Menu()->CountItems() > 0) {
|
||||
@ -492,7 +476,7 @@ GeneralView::Reload()
|
||||
if(item)
|
||||
item->SetMarked(false);
|
||||
}
|
||||
|
||||
|
||||
if(Addon()->CountAuthenticators() > 0) {
|
||||
BString kernelModule, authenticator;
|
||||
BMessage authentication;
|
||||
@ -513,11 +497,11 @@ GeneralView::Reload()
|
||||
fAuthenticatorDefault->SetMarked(true);
|
||||
else
|
||||
fAuthenticatorNone->SetMarked(true);
|
||||
|
||||
|
||||
fUsername->SetText(Addon()->Username());
|
||||
fPassword->SetText(Addon()->Password());
|
||||
fSavePassword->SetValue(Addon()->HasPassword());
|
||||
|
||||
|
||||
ReloadDeviceView();
|
||||
UpdateControls();
|
||||
}
|
||||
@ -528,7 +512,7 @@ GeneralView::DeviceName() const
|
||||
{
|
||||
if(fDeviceAddon)
|
||||
return fDeviceAddon->KernelModuleName();
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -539,7 +523,7 @@ GeneralView::AuthenticatorName() const
|
||||
BMenuItem *marked = fAuthenticatorField->Menu()->FindMarked();
|
||||
if(marked && marked != fAuthenticatorNone)
|
||||
return marked->Message()->FindString("KernelModuleName");
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -579,15 +563,15 @@ GeneralView::MessageReceived(BMessage *message)
|
||||
if(fDeviceAddon != Addon()->DeviceAddon())
|
||||
fDeviceAddon->LoadSettings(Addon()->Settings(), Addon()->Profile(),
|
||||
Addon()->IsNew());
|
||||
|
||||
|
||||
ReloadDeviceView();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case kMsgSelectAuthenticator:
|
||||
UpdateControls();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
@ -600,17 +584,17 @@ GeneralView::ReloadDeviceView()
|
||||
// first remove existing device view(s)
|
||||
while(fDeviceBox->CountChildren() > 1)
|
||||
fDeviceBox->RemoveChild(fDeviceBox->ChildAt(1));
|
||||
|
||||
|
||||
if(!fDeviceAddon)
|
||||
return;
|
||||
|
||||
|
||||
BRect rect(fDeviceBox->Bounds());
|
||||
float width, height;
|
||||
if(!fDeviceAddon->GetPreferredSize(&width, &height)) {
|
||||
width = rect.Width();
|
||||
height = 50;
|
||||
}
|
||||
|
||||
|
||||
if(width > rect.Width())
|
||||
width = rect.Width();
|
||||
if(height < 10)
|
||||
@ -619,7 +603,7 @@ GeneralView::ReloadDeviceView()
|
||||
else if(height > 200)
|
||||
height = 200;
|
||||
// set maximum height
|
||||
|
||||
|
||||
rect.InsetBy((rect.Width() - width) / 2, 0);
|
||||
// center horizontally
|
||||
rect.top = 25;
|
||||
@ -627,7 +611,7 @@ GeneralView::ReloadDeviceView()
|
||||
float deltaY = height + 30 - fDeviceBox->Bounds().Height();
|
||||
fDeviceBox->ResizeBy(0, deltaY);
|
||||
fAuthenticationBox->MoveBy(0, deltaY);
|
||||
|
||||
|
||||
BView *deviceView = fDeviceAddon->CreateView(rect.LeftTop());
|
||||
if(deviceView)
|
||||
fDeviceBox->AddChild(deviceView);
|
||||
@ -641,7 +625,7 @@ GeneralView::UpdateControls()
|
||||
int32 index = menu->IndexOf(menu->FindMarked());
|
||||
if(index < 0)
|
||||
fAuthenticatorNone->SetMarked(true);
|
||||
|
||||
|
||||
if(index == 0) {
|
||||
fUsername->SetEnabled(false);
|
||||
fPassword->SetEnabled(false);
|
||||
@ -671,7 +655,7 @@ GeneralView::AddAuthenticators()
|
||||
fAuthenticatorField->Menu()->AddItem(fAuthenticatorNone);
|
||||
fAuthenticatorNone->SetMarked(true);
|
||||
fAuthenticatorField->Menu()->AddSeparatorItem();
|
||||
|
||||
|
||||
BMenuItem *item;
|
||||
BMessage addon;
|
||||
for(int32 index = 0;
|
||||
@ -679,7 +663,7 @@ GeneralView::AddAuthenticators()
|
||||
&addon) == B_OK; index++) {
|
||||
BMessage *message = new BMessage(kMsgSelectAuthenticator);
|
||||
message->AddString("KernelModuleName", addon.FindString("KernelModuleName"));
|
||||
|
||||
|
||||
BString name, technicalName, friendlyName;
|
||||
bool hasTechnicalName
|
||||
= (addon.FindString("TechnicalName", &technicalName) == B_OK);
|
||||
@ -695,7 +679,7 @@ GeneralView::AddAuthenticators()
|
||||
if(hasTechnicalName)
|
||||
name << ")";
|
||||
}
|
||||
|
||||
|
||||
int32 insertAt = FindNextMenuInsertionIndex(fAuthenticatorField->Menu(),
|
||||
name.String(), 2);
|
||||
item = new BMenuItem(name.String(), message);
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// GeneralAddon saves the loaded settings.
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// IPCPAddon saves the loaded settings.
|
||||
@ -78,38 +62,38 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
fIPAddress = fPrimaryDNS = fSecondaryDNS = "";
|
||||
fSettings = settings;
|
||||
fProfile = profile;
|
||||
|
||||
|
||||
if(fIPCPView)
|
||||
fIPCPView->Reload();
|
||||
// reset all views (empty settings)
|
||||
|
||||
|
||||
if(!settings || !profile || isNew)
|
||||
return true;
|
||||
|
||||
|
||||
BMessage protocol;
|
||||
|
||||
|
||||
// settings
|
||||
int32 protocolIndex = FindIPCPProtocol(*fSettings, &protocol);
|
||||
if(protocolIndex < 0)
|
||||
return true;
|
||||
|
||||
|
||||
protocol.AddBool(MDSU_VALID, true);
|
||||
fSettings->ReplaceMessage(MDSU_PARAMETERS, protocolIndex, &protocol);
|
||||
|
||||
|
||||
// profile
|
||||
protocolIndex = FindIPCPProtocol(*fProfile, &protocol);
|
||||
if(protocolIndex < 0)
|
||||
return true;
|
||||
|
||||
|
||||
fIsEnabled = true;
|
||||
|
||||
|
||||
// the "Local" side parameter
|
||||
BMessage local;
|
||||
int32 localSideIndex = 0;
|
||||
if(!FindMessageParameter(IPCP_LOCAL_SIDE_KEY, protocol, &local, &localSideIndex))
|
||||
local.MakeEmpty();
|
||||
// just fall through and pretend we have an empty "Local" side parameter
|
||||
|
||||
|
||||
// now load the supported parameters (the client-relevant subset)
|
||||
BString name;
|
||||
BMessage parameter;
|
||||
@ -120,11 +104,11 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
else {
|
||||
if(fIPAddress == "auto")
|
||||
fIPAddress = "";
|
||||
|
||||
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
local.ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
index = 0;
|
||||
if(!FindMessageParameter(IPCP_PRIMARY_DNS_KEY, local, ¶meter, &index)
|
||||
|| parameter.FindString(MDSU_VALUES, &fPrimaryDNS) != B_OK)
|
||||
@ -132,11 +116,11 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
else {
|
||||
if(fPrimaryDNS == "auto")
|
||||
fPrimaryDNS = "";
|
||||
|
||||
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
local.ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
index = 0;
|
||||
if(!FindMessageParameter(IPCP_SECONDARY_DNS_KEY, local, ¶meter, &index)
|
||||
|| parameter.FindString(MDSU_VALUES, &fSecondaryDNS) != B_OK)
|
||||
@ -144,19 +128,19 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
else {
|
||||
if(fSecondaryDNS == "auto")
|
||||
fSecondaryDNS = "";
|
||||
|
||||
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
local.ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
local.AddBool(MDSU_VALID, true);
|
||||
protocol.ReplaceMessage(MDSU_PARAMETERS, localSideIndex, &local);
|
||||
protocol.AddBool(MDSU_VALID, true);
|
||||
fProfile->ReplaceMessage(MDSU_PARAMETERS, protocolIndex, &protocol);
|
||||
|
||||
|
||||
if(fIPCPView)
|
||||
fIPCPView->Reload();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -168,7 +152,7 @@ IPCPAddon::IsModified(bool *settings, bool *profile) const
|
||||
*settings = *profile = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*settings = fIsEnabled != fIPCPView->IsEnabled();
|
||||
*profile = (*settings || fIPAddress != fIPCPView->IPAddress()
|
||||
|| fPrimaryDNS != fIPCPView->PrimaryDNS()
|
||||
@ -181,20 +165,20 @@ IPCPAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporar
|
||||
{
|
||||
if(!fSettings || !settings)
|
||||
return false;
|
||||
|
||||
|
||||
if(!fIPCPView->IsEnabled())
|
||||
return true;
|
||||
|
||||
|
||||
BMessage protocol, local;
|
||||
protocol.AddString(MDSU_NAME, PPP_PROTOCOL_KEY);
|
||||
protocol.AddString(MDSU_VALUES, kKernelModuleName);
|
||||
settings->AddMessage(MDSU_PARAMETERS, &protocol);
|
||||
// the settings contain a simple "protocol ipcp" string
|
||||
|
||||
|
||||
// now create the profile with all subparameters
|
||||
local.AddString(MDSU_NAME, IPCP_LOCAL_SIDE_KEY);
|
||||
bool needsLocal = false;
|
||||
|
||||
|
||||
if(fIPCPView->IPAddress() && strlen(fIPCPView->IPAddress()) > 0) {
|
||||
// save IP address, too
|
||||
needsLocal = true;
|
||||
@ -203,7 +187,7 @@ IPCPAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporar
|
||||
ip.AddString(MDSU_VALUES, fIPCPView->IPAddress());
|
||||
local.AddMessage(MDSU_PARAMETERS, &ip);
|
||||
}
|
||||
|
||||
|
||||
if(fIPCPView->PrimaryDNS() && strlen(fIPCPView->PrimaryDNS()) > 0) {
|
||||
// save service name, too
|
||||
needsLocal = true;
|
||||
@ -212,7 +196,7 @@ IPCPAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporar
|
||||
dns.AddString(MDSU_VALUES, fIPCPView->PrimaryDNS());
|
||||
local.AddMessage(MDSU_PARAMETERS, &dns);
|
||||
}
|
||||
|
||||
|
||||
if(fIPCPView->SecondaryDNS() && strlen(fIPCPView->SecondaryDNS()) > 0) {
|
||||
// save service name, too
|
||||
needsLocal = true;
|
||||
@ -221,12 +205,12 @@ IPCPAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporar
|
||||
dns.AddString(MDSU_VALUES, fIPCPView->SecondaryDNS());
|
||||
local.AddMessage(MDSU_PARAMETERS, &dns);
|
||||
}
|
||||
|
||||
|
||||
if(needsLocal)
|
||||
protocol.AddMessage(MDSU_PARAMETERS, &local);
|
||||
|
||||
|
||||
profile->AddMessage(MDSU_PARAMETERS, &protocol);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -238,12 +222,12 @@ IPCPAddon::GetPreferredSize(float *width, float *height) const
|
||||
if(Addons()->FindRect(DUN_TAB_VIEW_RECT, &rect) != B_OK)
|
||||
rect.Set(0, 0, 200, 300);
|
||||
// set default values
|
||||
|
||||
|
||||
if(width)
|
||||
*width = rect.Width();
|
||||
if(height)
|
||||
*height = rect.Height();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -257,7 +241,7 @@ IPCPAddon::CreateView(BPoint leftTop)
|
||||
fIPCPView = new IPCPView(this, rect);
|
||||
fIPCPView->Reload();
|
||||
}
|
||||
|
||||
|
||||
fIPCPView->MoveTo(leftTop);
|
||||
return fIPCPView;
|
||||
}
|
||||
@ -268,14 +252,14 @@ IPCPAddon::FindIPCPProtocol(const BMessage& message, BMessage *protocol) const
|
||||
{
|
||||
if(!protocol)
|
||||
return -1;
|
||||
|
||||
|
||||
BString name;
|
||||
for(int32 index = 0; FindMessageParameter(PPP_PROTOCOL_KEY, message, protocol,
|
||||
&index); index++)
|
||||
if(protocol->FindString(MDSU_VALUES, &name) == B_OK
|
||||
&& name == kKernelModuleName)
|
||||
return index;
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -313,14 +297,14 @@ IPCPView::IPCPView(IPCPAddon *addon, BRect frame)
|
||||
rect.bottom = rect.top + 15;
|
||||
fIsEnabled = new BCheckBox(rect, "isEnabled", kLabelEnabled,
|
||||
new BMessage(kMsgUpdateControls));
|
||||
|
||||
|
||||
// set divider of text controls
|
||||
float controlWidth = max(max(StringWidth(fIPAddress->Label()),
|
||||
StringWidth(fPrimaryDNS->Label())), StringWidth(fSecondaryDNS->Label()));
|
||||
fIPAddress->SetDivider(controlWidth + 5);
|
||||
fPrimaryDNS->SetDivider(controlWidth + 5);
|
||||
fSecondaryDNS->SetDivider(controlWidth + 5);
|
||||
|
||||
|
||||
AddChild(fIsEnabled);
|
||||
AddChild(fIPAddress);
|
||||
AddChild(fPrimaryDNS);
|
||||
@ -336,7 +320,7 @@ IPCPView::Reload()
|
||||
fIPAddress->SetText(Addon()->IPAddress());
|
||||
fPrimaryDNS->SetText(Addon()->PrimaryDNS());
|
||||
fSecondaryDNS->SetText(Addon()->SecondaryDNS());
|
||||
|
||||
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
@ -356,7 +340,7 @@ IPCPView::MessageReceived(BMessage *message)
|
||||
case kMsgUpdateControls:
|
||||
UpdateControls();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// IPCPAddon saves the loaded settings.
|
||||
|
@ -1,24 +1,9 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "InterfaceUtils.h"
|
||||
|
||||
@ -40,7 +25,7 @@ center_on_screen(BRect rect, BWindow *window)
|
||||
(screenFrame.Height() - rect.Height()) / 2.0);
|
||||
if(!screenFrame.Contains(point))
|
||||
point.Set(0, 0);
|
||||
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
@ -54,7 +39,7 @@ FindNextMenuInsertionIndex(BMenu *menu, const char *name, int32 index)
|
||||
if(item && strcasecmp(name, item->Label()) <= 0)
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -69,7 +54,7 @@ FindNextListInsertionIndex(BListView *list, const char *name)
|
||||
if(item && strcasecmp(name, item->Text()) <= 0)
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -82,10 +67,10 @@ AddAddonsToMenu(const BMessage *source, BMenu *menu, const char *type, uint32 wh
|
||||
reinterpret_cast<void**>(&addon)) == B_OK; index++) {
|
||||
if(!addon || (!addon->FriendlyName() && !addon->TechnicalName()))
|
||||
continue;
|
||||
|
||||
|
||||
BMessage *message = new BMessage(what);
|
||||
message->AddPointer("Addon", addon);
|
||||
|
||||
|
||||
BString name;
|
||||
if(addon->TechnicalName()) {
|
||||
name << addon->TechnicalName();
|
||||
@ -97,7 +82,7 @@ AddAddonsToMenu(const BMessage *source, BMenu *menu, const char *type, uint32 wh
|
||||
if(addon->TechnicalName())
|
||||
name << ")";
|
||||
}
|
||||
|
||||
|
||||
int32 insertAt = FindNextMenuInsertionIndex(menu, name.String());
|
||||
menu->AddItem(new BMenuItem(name.String(), message), insertAt);
|
||||
}
|
||||
|
@ -1,25 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _INTERFACE_UTILS__H
|
||||
#define _INTERFACE_UTILS__H
|
||||
|
||||
|
@ -1,24 +1,9 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "MessageDriverSettingsUtils.h"
|
||||
|
||||
@ -49,7 +34,7 @@ FindMessageParameter(const char *name, const BMessage& message, BMessage *save,
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -63,7 +48,7 @@ AddValues(const BMessage& message, driver_parameter *parameter)
|
||||
index++)
|
||||
if(!add_driver_parameter_value(value, parameter))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,7 +59,7 @@ AddParameters(const BMessage& message, driver_parameter *to)
|
||||
{
|
||||
if(!to)
|
||||
return false;
|
||||
|
||||
|
||||
return AddParameters(message,
|
||||
reinterpret_cast<driver_settings*>(&to->parameter_count));
|
||||
}
|
||||
@ -93,11 +78,11 @@ AddParameters(const BMessage& message, driver_settings *to)
|
||||
parameter = new_driver_parameter(name);
|
||||
if(!AddValues(current, parameter))
|
||||
return false;
|
||||
|
||||
|
||||
AddParameters(current, parameter);
|
||||
add_driver_parameter(parameter, to);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -106,12 +91,12 @@ driver_settings*
|
||||
MessageToDriverSettings(const BMessage& message)
|
||||
{
|
||||
driver_settings *settings = new_driver_settings();
|
||||
|
||||
|
||||
if(!AddParameters(message, settings)) {
|
||||
free_driver_settings(settings);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -122,22 +107,22 @@ AddParameter(const driver_parameter *parameter, BMessage *message)
|
||||
{
|
||||
if(!parameter || !message)
|
||||
return false;
|
||||
|
||||
|
||||
if(parameter->name)
|
||||
message->AddString(MDSU_NAME, parameter->name);
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
for(int32 index = 0; index < parameter->value_count; index++)
|
||||
if(parameter->values[index])
|
||||
message->AddString(MDSU_VALUES, parameter->values[index]);
|
||||
|
||||
|
||||
for(int32 index = 0; index < parameter->parameter_count; index++) {
|
||||
BMessage parameterMessage;
|
||||
AddParameter(¶meter->parameters[index], ¶meterMessage);
|
||||
message->AddMessage(MDSU_PARAMETERS, ¶meterMessage);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -147,7 +132,7 @@ ReadMessageDriverSettings(const char *name, BMessage *message)
|
||||
{
|
||||
if(!name || !message)
|
||||
return false;
|
||||
|
||||
|
||||
void *handle = load_driver_settings(name);
|
||||
if(!handle)
|
||||
return false;
|
||||
@ -156,15 +141,15 @@ ReadMessageDriverSettings(const char *name, BMessage *message)
|
||||
unload_driver_settings(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for(int32 index = 0; index < settings->parameter_count; index++) {
|
||||
BMessage parameter;
|
||||
AddParameter(&settings->parameters[index], ¶meter);
|
||||
message->AddMessage(MDSU_PARAMETERS, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
unload_driver_settings(handle);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -187,7 +172,7 @@ WriteParameter(BFile& file, const BMessage& parameter, int32 level)
|
||||
const char *name;
|
||||
if(parameter.FindString(MDSU_NAME, &name) != B_OK || !name)
|
||||
return false;
|
||||
|
||||
|
||||
BString line, word(name);
|
||||
EscapeWord(word);
|
||||
bool needsEscaping = word.FindFirst(' ') >= 0;
|
||||
@ -197,7 +182,7 @@ WriteParameter(BFile& file, const BMessage& parameter, int32 level)
|
||||
line << word;
|
||||
if(needsEscaping)
|
||||
line << '\"';
|
||||
|
||||
|
||||
for(int32 index = 0; parameter.FindString(MDSU_VALUES, index, &name) == B_OK;
|
||||
index++)
|
||||
if(name) {
|
||||
@ -211,28 +196,28 @@ WriteParameter(BFile& file, const BMessage& parameter, int32 level)
|
||||
if(needsEscaping)
|
||||
line << '\"';
|
||||
}
|
||||
|
||||
|
||||
type_code type;
|
||||
int32 parameterCount;
|
||||
parameter.GetInfo(MDSU_PARAMETERS, &type, ¶meterCount);
|
||||
|
||||
|
||||
if(parameterCount > 0)
|
||||
line << " {";
|
||||
|
||||
|
||||
line << '\n';
|
||||
file.Write(line.String(), line.Length());
|
||||
|
||||
|
||||
if(parameterCount > 0) {
|
||||
BMessage subParameter;
|
||||
for(int32 index = 0; parameter.FindMessage(MDSU_PARAMETERS, index,
|
||||
&subParameter) == B_OK; index++)
|
||||
WriteParameter(file, subParameter, level + 1);
|
||||
|
||||
|
||||
line.SetTo('\t', level);
|
||||
line << "}\n";
|
||||
file.Write(line.String(), line.Length());
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -242,10 +227,10 @@ WriteMessageDriverSettings(BFile& file, const BMessage& message)
|
||||
{
|
||||
if(file.InitCheck() != B_OK || !file.IsWritable())
|
||||
return false;
|
||||
|
||||
|
||||
file.SetSize(0);
|
||||
file.Seek(0, SEEK_SET);
|
||||
|
||||
|
||||
BMessage parameter;
|
||||
for(int32 index = 0; message.FindMessage(MDSU_PARAMETERS, index, ¶meter) == B_OK;
|
||||
index++) {
|
||||
@ -253,6 +238,6 @@ WriteMessageDriverSettings(BFile& file, const BMessage& message)
|
||||
file.Write("\n", 1);
|
||||
WriteParameter(file, parameter, 0);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,25 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _MESSAGE_DRIVER_SETTINGS_UTILS__H
|
||||
#define _MESSAGE_DRIVER_SETTINGS_UTILS__H
|
||||
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// PPPoEAddon saves the loaded settings.
|
||||
@ -118,24 +102,24 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
fInterfaceName = fServiceName = "";
|
||||
fSettings = settings;
|
||||
fProfile = profile;
|
||||
|
||||
|
||||
if(fPPPoEView)
|
||||
fPPPoEView->Reload();
|
||||
|
||||
|
||||
if(!settings || !profile || isNew)
|
||||
return true;
|
||||
|
||||
|
||||
BMessage device;
|
||||
int32 deviceIndex = 0;
|
||||
if(!FindMessageParameter(PPP_DEVICE_KEY, *fSettings, &device, &deviceIndex))
|
||||
return false;
|
||||
// error: no device
|
||||
|
||||
|
||||
BString name;
|
||||
if(device.FindString(MDSU_VALUES, &name) != B_OK || name != kKernelModuleName)
|
||||
return false;
|
||||
// error: no device
|
||||
|
||||
|
||||
BMessage parameter;
|
||||
int32 index = 0;
|
||||
if(!FindMessageParameter(PPPoE_INTERFACE_KEY, device, ¶meter, &index)
|
||||
@ -146,7 +130,7 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
device.ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
index = 0;
|
||||
if(!FindMessageParameter(PPPoE_SERVICE_NAME_KEY, device, ¶meter, &index)
|
||||
|| parameter.FindString(MDSU_VALUES, &fServiceName) != B_OK)
|
||||
@ -155,13 +139,13 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
device.ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
|
||||
device.AddBool(MDSU_VALID, true);
|
||||
fSettings->ReplaceMessage(MDSU_PARAMETERS, deviceIndex, &device);
|
||||
|
||||
|
||||
if(fPPPoEView)
|
||||
fPPPoEView->Reload();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -170,12 +154,12 @@ void
|
||||
PPPoEAddon::IsModified(bool *settings, bool *profile) const
|
||||
{
|
||||
*profile = false;
|
||||
|
||||
|
||||
if(!fSettings) {
|
||||
*settings = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*settings = (fInterfaceName != fPPPoEView->InterfaceName()
|
||||
|| fServiceName != fPPPoEView->ServiceName());
|
||||
}
|
||||
@ -188,15 +172,15 @@ PPPoEAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTempora
|
||||
|| strlen(fPPPoEView->InterfaceName()) == 0)
|
||||
return false;
|
||||
// TODO: tell user that an interface is needed (if we fail because of this)
|
||||
|
||||
|
||||
BMessage device, interface;
|
||||
device.AddString(MDSU_NAME, PPP_DEVICE_KEY);
|
||||
device.AddString(MDSU_VALUES, kKernelModuleName);
|
||||
|
||||
|
||||
interface.AddString(MDSU_NAME, PPPoE_INTERFACE_KEY);
|
||||
interface.AddString(MDSU_VALUES, fPPPoEView->InterfaceName());
|
||||
device.AddMessage(MDSU_PARAMETERS, &interface);
|
||||
|
||||
|
||||
if(fPPPoEView->ServiceName() && strlen(fPPPoEView->ServiceName()) > 0) {
|
||||
// save service name, too
|
||||
BMessage service;
|
||||
@ -204,9 +188,9 @@ PPPoEAddon::SaveSettings(BMessage *settings, BMessage *profile, bool saveTempora
|
||||
service.AddString(MDSU_VALUES, fPPPoEView->ServiceName());
|
||||
device.AddMessage(MDSU_PARAMETERS, &service);
|
||||
}
|
||||
|
||||
|
||||
settings->AddMessage(MDSU_PARAMETERS, &device);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -218,12 +202,12 @@ PPPoEAddon::GetPreferredSize(float *width, float *height) const
|
||||
if(Addons()->FindFloat(DUN_DEVICE_VIEW_WIDTH, &viewWidth) != B_OK)
|
||||
viewWidth = 270;
|
||||
// default value
|
||||
|
||||
|
||||
if(width)
|
||||
*width = viewWidth;
|
||||
if(height)
|
||||
*height = fHeight;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -236,12 +220,12 @@ PPPoEAddon::CreateView(BPoint leftTop)
|
||||
if(!Addons()->FindFloat(DUN_DEVICE_VIEW_WIDTH, &width))
|
||||
width = 270;
|
||||
// default value
|
||||
|
||||
|
||||
BRect rect(0, 0, width, fHeight);
|
||||
fPPPoEView = new PPPoEView(this, rect);
|
||||
fPPPoEView->Reload();
|
||||
}
|
||||
|
||||
|
||||
fPPPoEView->MoveTo(leftTop);
|
||||
return fPPPoEView;
|
||||
}
|
||||
@ -270,7 +254,7 @@ PPPoEView::PPPoEView(PPPoEAddon *addon, BRect frame)
|
||||
rect.right += 75;
|
||||
rect.bottom = rect.top + 15;
|
||||
AddChild(new BStringView(rect, "optional", kLabelOptional));
|
||||
|
||||
|
||||
AddChild(fInterface);
|
||||
AddChild(fServiceName);
|
||||
}
|
||||
@ -308,17 +292,17 @@ PPPoEView::MessageReceived(BMessage *message)
|
||||
if(item)
|
||||
fInterfaceName = item->Label();
|
||||
} break;
|
||||
|
||||
|
||||
case kMsgSelectOther:
|
||||
(new TextRequestDialog("InterfaceName", NULL, kRequestInterfaceName,
|
||||
fInterfaceName.String()))->Go(new BInvoker(
|
||||
new BMessage(kMsgFinishSelectOther), this));
|
||||
break;
|
||||
|
||||
|
||||
case kMsgFinishSelectOther: {
|
||||
int32 which;
|
||||
message->FindInt32("which", &which);
|
||||
|
||||
|
||||
const char *name = message->FindString("text");
|
||||
BMenu *menu = fInterface->Menu();
|
||||
BMenuItem *item;
|
||||
@ -328,25 +312,25 @@ PPPoEView::MessageReceived(BMessage *message)
|
||||
item->SetMarked(true);
|
||||
else
|
||||
fOtherInterface->SetMarked(true);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fInterfaceName = name;
|
||||
|
||||
|
||||
item = menu->FindItem(fInterfaceName.String());
|
||||
if(item && menu->IndexOf(item) <= menu->CountItems() - 2) {
|
||||
item->SetMarked(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BString label(kLabelOtherInterface);
|
||||
label << " " << name;
|
||||
fOtherInterface->SetLabel(label.String());
|
||||
fOtherInterface->SetMarked(true);
|
||||
// XXX: this is needed to tell the owning menu to update its label
|
||||
} break;
|
||||
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
@ -361,13 +345,13 @@ PPPoEView::ReloadInterfaces()
|
||||
while(menu->CountItems() > 2)
|
||||
delete menu->RemoveItem((int32) 0);
|
||||
fOtherInterface->SetLabel(kLabelOtherInterface);
|
||||
|
||||
|
||||
PPPManager manager;
|
||||
char *interfaces = new char[8192];
|
||||
// reserve enough space for approximately 512 entries
|
||||
int32 count = manager.ControlModule("pppoe", PPPoE_GET_INTERFACES, interfaces,
|
||||
8192);
|
||||
|
||||
|
||||
BMenuItem *item;
|
||||
char *name = interfaces;
|
||||
int32 insertAt;
|
||||
@ -376,12 +360,12 @@ PPPoEView::ReloadInterfaces()
|
||||
insertAt = FindNextMenuInsertionIndex(menu, name);
|
||||
if(insertAt > menu->CountItems() - 2)
|
||||
insertAt = menu->CountItems() - 2;
|
||||
|
||||
|
||||
item->SetTarget(this);
|
||||
menu->AddItem(item, insertAt);
|
||||
name += strlen(name) + 1;
|
||||
}
|
||||
|
||||
|
||||
// set interface or some default value if nothing was found
|
||||
if(Addon()->InterfaceName() && strlen(Addon()->InterfaceName()) > 0)
|
||||
fInterfaceName = Addon()->InterfaceName();
|
||||
@ -389,9 +373,9 @@ PPPoEView::ReloadInterfaces()
|
||||
fInterfaceName = interfaces;
|
||||
else
|
||||
fInterfaceName = "";
|
||||
|
||||
|
||||
delete interfaces;
|
||||
|
||||
|
||||
item = menu->FindItem(fInterfaceName.String());
|
||||
if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
|
||||
item->SetMarked(true);
|
||||
|
@ -1,24 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// PPPoEAddon saves the loaded settings.
|
||||
|
@ -1,24 +1,9 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "TextRequestDialog.h"
|
||||
#include "InterfaceUtils.h"
|
||||
@ -54,7 +39,7 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *information,
|
||||
rect.InsetBy(5, 5);
|
||||
rect.bottom = rect.top;
|
||||
// init
|
||||
|
||||
|
||||
if(information) {
|
||||
BRect textRect(rect);
|
||||
textRect.OffsetTo(0, 0);
|
||||
@ -72,7 +57,7 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *information,
|
||||
backgroundView->AddChild(fTextView);
|
||||
} else
|
||||
fTextView = NULL;
|
||||
|
||||
|
||||
rect.top = rect.bottom + 5;
|
||||
rect.bottom = rect.top + 20;
|
||||
fTextControl = new BTextControl(rect, "request", request, text, NULL);
|
||||
@ -80,7 +65,7 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *information,
|
||||
fTextControl->SetDivider(fTextControl->StringWidth(fTextControl->Label()) + 5);
|
||||
if(text && strlen(text) > 0)
|
||||
fTextControl->TextView()->SelectAll();
|
||||
|
||||
|
||||
rect.top = rect.bottom + 10;
|
||||
rect.bottom = rect.top + 25;
|
||||
rect.left = rect.right - kDefaultButtonWidth;
|
||||
@ -96,10 +81,10 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *information,
|
||||
backgroundView->AddChild(fOKButton);
|
||||
backgroundView->AddChild(fTextControl);
|
||||
AddChild(backgroundView);
|
||||
|
||||
|
||||
fTextControl->MakeFocus(true);
|
||||
SetDefaultButton(fOKButton);
|
||||
|
||||
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
@ -117,22 +102,22 @@ TextRequestDialog::MessageReceived(BMessage *message)
|
||||
case kMsgButton: {
|
||||
if(!fInvoker || !fInvoker->Message())
|
||||
return;
|
||||
|
||||
|
||||
int32 which;
|
||||
message->FindInt32("which", &which);
|
||||
BMessage toSend(*fInvoker->Message());
|
||||
toSend.AddInt32("which", which);
|
||||
if(which == 1)
|
||||
toSend.AddString("text", fTextControl->Text());
|
||||
|
||||
|
||||
fInvoker->Invoke(&toSend);
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
} break;
|
||||
|
||||
|
||||
case kMsgUpdateControls:
|
||||
UpdateControls();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
@ -152,7 +137,7 @@ TextRequestDialog::Go(BInvoker *invoker)
|
||||
fInvoker = invoker;
|
||||
MoveTo(center_on_screen(Bounds()));
|
||||
Show();
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,8 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* 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 Waldemar Kornewald. All rights reserved.
|
||||
* Copyright 2017 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _TEXT_REQUEST_DIALOG__H
|
||||
#define _TEXT_REQUEST_DIALOG__H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user