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