Renamed "Dial" to "Connect".
Added checkbox for setting default interface (not yet implemented). Simplified "Options" tab (no ConnectOnDemand anymore). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10497 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0cbb739d3b
commit
7577e5e2c4
|
@ -22,15 +22,12 @@ static const uint32 kMsgUpdateControls = 'UCTL';
|
|||
// labels
|
||||
#ifdef LANG_GERMAN
|
||||
static const char *kLabelConnectionOptions = "Optionen";
|
||||
static const char *kLabelDialOnDemand = "Automatisch Verbinden Bei Zugriff Auf "
|
||||
"Internet";
|
||||
static const char *kLabelAskBeforeDialing = "Vor Dem Verbinden Fragen";
|
||||
static const char *kLabelAutoRedial = "Verbindung Automatisch Wiederherstellen";
|
||||
static const char *kLabelAskBeforeConnecting = "Vor Dem Verbinden Fragen";
|
||||
static const char *kLabelAutoReconnect = "Verbindung Automatisch Wiederherstellen";
|
||||
#else
|
||||
static const char *kLabelConnectionOptions = "Options";
|
||||
static const char *kLabelDialOnDemand = "Connect Automatically When Needed";
|
||||
static const char *kLabelAskBeforeDialing = "Ask Before Connecting";
|
||||
static const char *kLabelAutoRedial = "Reconnect Automatically";
|
||||
static const char *kLabelAskBeforeConnecting = "Ask Before Connecting";
|
||||
static const char *kLabelAutoReconnect = "Reconnect Automatically";
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -56,7 +53,7 @@ bool
|
|||
ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
{
|
||||
fIsNew = isNew;
|
||||
fDoesDialOnDemand = fAskBeforeDialing = fDoesAutoRedial = false;
|
||||
fAskBeforeConnecting = fDoesAutoReconnect = false;
|
||||
fSettings = settings;
|
||||
fProfile = profile;
|
||||
|
||||
|
@ -69,30 +66,20 @@ ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool
|
|||
BMessage parameter;
|
||||
int32 index = 0;
|
||||
const char *value;
|
||||
if(FindMessageParameter(PPP_DIAL_ON_DEMAND_KEY, *fSettings, ¶meter, &index)
|
||||
&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
|
||||
if(FindMessageParameter(PPP_ASK_BEFORE_CONNECTING_KEY, *fSettings, ¶meter,
|
||||
&index) && parameter.FindString(MDSU_VALUES, &value) == B_OK) {
|
||||
if(get_boolean_value(value, false))
|
||||
fDoesDialOnDemand = true;
|
||||
fAskBeforeConnecting = true;
|
||||
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
fSettings->ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
if(FindMessageParameter(PPP_ASK_BEFORE_DIALING_KEY, *fSettings, ¶meter, &index)
|
||||
if(FindMessageParameter(PPP_AUTO_RECONNECT_KEY, *fSettings, ¶meter, &index)
|
||||
&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
|
||||
if(get_boolean_value(value, false))
|
||||
fAskBeforeDialing = true;
|
||||
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
fSettings->ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
if(FindMessageParameter(PPP_AUTO_REDIAL_KEY, *fSettings, ¶meter, &index)
|
||||
&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
|
||||
if(get_boolean_value(value, false))
|
||||
fDoesAutoRedial = true;
|
||||
fDoesAutoReconnect = true;
|
||||
|
||||
parameter.AddBool(MDSU_VALID, true);
|
||||
fSettings->ReplaceMessage(MDSU_PARAMETERS, index, ¶meter);
|
||||
|
@ -113,9 +100,8 @@ ConnectionOptionsAddon::IsModified(bool *settings, bool *profile) const
|
|||
if(!fSettings || !fConnectionOptionsView)
|
||||
return;
|
||||
|
||||
*settings = DoesDialOnDemand() != fConnectionOptionsView->DoesDialOnDemand()
|
||||
|| AskBeforeDialing() != fConnectionOptionsView->AskBeforeDialing()
|
||||
|| DoesAutoRedial() != fConnectionOptionsView->DoesAutoRedial();
|
||||
*settings = AskBeforeConnecting() != fConnectionOptionsView->AskBeforeConnecting()
|
||||
|| DoesAutoReconnect() != fConnectionOptionsView->DoesAutoReconnect();
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,23 +113,9 @@ ConnectionOptionsAddon::SaveSettings(BMessage *settings, BMessage *profile,
|
|||
return false;
|
||||
|
||||
BMessage parameter;
|
||||
if(fConnectionOptionsView->DoesDialOnDemand()) {
|
||||
if(fConnectionOptionsView->DoesAutoReconnect()) {
|
||||
parameter.MakeEmpty();
|
||||
parameter.AddString(MDSU_NAME, PPP_DIAL_ON_DEMAND_KEY);
|
||||
parameter.AddString(MDSU_VALUES, "enabled");
|
||||
settings->AddMessage(MDSU_PARAMETERS, ¶meter);
|
||||
|
||||
if(fConnectionOptionsView->AskBeforeDialing()) {
|
||||
parameter.MakeEmpty();
|
||||
parameter.AddString(MDSU_NAME, PPP_ASK_BEFORE_DIALING_KEY);
|
||||
parameter.AddString(MDSU_VALUES, "enabled");
|
||||
settings->AddMessage(MDSU_PARAMETERS, ¶meter);
|
||||
}
|
||||
}
|
||||
|
||||
if(fConnectionOptionsView->DoesAutoRedial()) {
|
||||
parameter.MakeEmpty();
|
||||
parameter.AddString(MDSU_NAME, PPP_AUTO_REDIAL_KEY);
|
||||
parameter.AddString(MDSU_NAME, PPP_AUTO_RECONNECT_KEY);
|
||||
parameter.AddString(MDSU_VALUES, "enabled");
|
||||
settings->AddMessage(MDSU_PARAMETERS, ¶meter);
|
||||
}
|
||||
|
@ -193,36 +165,25 @@ ConnectionOptionsView::ConnectionOptionsView(ConnectionOptionsAddon *addon, BRec
|
|||
BRect rect = Bounds();
|
||||
rect.InsetBy(10, 10);
|
||||
rect.bottom = rect.top + 15;
|
||||
fDialOnDemand = new BCheckBox(rect, "DialOnDemand", kLabelDialOnDemand,
|
||||
new BMessage(kMsgUpdateControls));
|
||||
rect.top = rect.bottom + 3;
|
||||
fAskBeforeConnecting = new BCheckBox(rect, "AskBeforeConnecting",
|
||||
kLabelAskBeforeConnecting, NULL);
|
||||
rect.top = rect.bottom + 5;
|
||||
rect.bottom = rect.top + 15;
|
||||
rect.left += 20;
|
||||
fAskBeforeDialing = new BCheckBox(rect, "AskBeforeDialing", kLabelAskBeforeDialing,
|
||||
NULL);
|
||||
rect.left -= 20;
|
||||
rect.top = rect.bottom + 20;
|
||||
rect.bottom = rect.top + 15;
|
||||
fAutoRedial = new BCheckBox(rect, "AutoRedial", kLabelAutoRedial, NULL);
|
||||
fAutoReconnect = new BCheckBox(rect, "AutoReconnect", kLabelAutoReconnect, NULL);
|
||||
|
||||
AddChild(fDialOnDemand);
|
||||
AddChild(fAskBeforeDialing);
|
||||
AddChild(fAutoRedial);
|
||||
AddChild(fAskBeforeConnecting);
|
||||
AddChild(fAutoReconnect);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConnectionOptionsView::Reload()
|
||||
{
|
||||
fDialOnDemand->SetValue(Addon()->DoesDialOnDemand() || Addon()->IsNew());
|
||||
// this is enabled by default
|
||||
fAskBeforeDialing->SetValue(Addon()->AskBeforeDialing());
|
||||
fAutoRedial->SetValue(Addon()->DoesAutoRedial());
|
||||
fAskBeforeConnecting->SetValue(Addon()->AskBeforeConnecting());
|
||||
fAutoReconnect->SetValue(Addon()->DoesAutoReconnect());
|
||||
|
||||
if(!Addon()->Settings())
|
||||
return;
|
||||
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,27 +191,4 @@ void
|
|||
ConnectionOptionsView::AttachedToWindow()
|
||||
{
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
fDialOnDemand->SetTarget(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConnectionOptionsView::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(message->what) {
|
||||
case kMsgUpdateControls:
|
||||
UpdateControls();
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConnectionOptionsView::UpdateControls()
|
||||
{
|
||||
fAskBeforeDialing->SetEnabled(fDialOnDemand->Value());
|
||||
fAskBeforeDialing->SetValue(fDialOnDemand->Value());
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ class ConnectionOptionsAddon : public DialUpAddon {
|
|||
bool IsNew() const
|
||||
{ return fIsNew; }
|
||||
|
||||
bool DoesDialOnDemand() const
|
||||
{ return fDoesDialOnDemand; }
|
||||
bool AskBeforeDialing() const
|
||||
{ return fAskBeforeDialing; }
|
||||
bool DoesAutoRedial() const
|
||||
{ return fDoesAutoRedial; }
|
||||
bool AskBeforeConnecting() const
|
||||
{ return fAskBeforeConnecting; }
|
||||
bool DoesAutoReconnect() const
|
||||
{ return fDoesAutoReconnect; }
|
||||
|
||||
BMessage *Settings() const
|
||||
{ return fSettings; }
|
||||
|
@ -50,7 +48,7 @@ class ConnectionOptionsAddon : public DialUpAddon {
|
|||
|
||||
private:
|
||||
bool fIsNew, fDeleteView;
|
||||
bool fDoesDialOnDemand, fAskBeforeDialing, fDoesAutoRedial;
|
||||
bool fAskBeforeConnecting, fDoesAutoReconnect;
|
||||
BMessage *fSettings, *fProfile;
|
||||
// saves last settings state
|
||||
ConnectionOptionsView *fConnectionOptionsView;
|
||||
|
@ -65,22 +63,16 @@ class ConnectionOptionsView : public BView {
|
|||
{ return fAddon; }
|
||||
void Reload();
|
||||
|
||||
bool DoesDialOnDemand() const
|
||||
{ return fDialOnDemand->Value(); }
|
||||
bool AskBeforeDialing() const
|
||||
{ return fAskBeforeDialing->Value(); }
|
||||
bool DoesAutoRedial() const
|
||||
{ return fAutoRedial->Value(); }
|
||||
bool AskBeforeConnecting() const
|
||||
{ return fAskBeforeConnecting->Value(); }
|
||||
bool DoesAutoReconnect() const
|
||||
{ return fAutoReconnect->Value(); }
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
void UpdateControls();
|
||||
|
||||
private:
|
||||
ConnectionOptionsAddon *fAddon;
|
||||
BCheckBox *fDialOnDemand, *fAskBeforeDialing, *fAutoRedial;
|
||||
BCheckBox *fAskBeforeConnecting, *fAutoReconnect;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/*! \class DialUpAddon
|
||||
\brief Base class for DialUpPreflet add-ons.
|
||||
|
||||
Dial-Up add-ons must export the following function: \n
|
||||
Connect-Up add-ons must export the following function: \n
|
||||
bool register(BMessage *addons) \n
|
||||
You should add your DialUpAddon object to the given BMessage. \n
|
||||
\n
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "DialUpView.h"
|
||||
|
||||
|
||||
static const char *kSignature = "application/x-vnd.haiku.dial-up-preflet";
|
||||
static const char *kSignature = "application/x-vnd.haiku.connect-up-preflet";
|
||||
|
||||
|
||||
class DialUpApplication : public BApplication {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
DialUpPreflet.rdef
|
||||
*/
|
||||
|
||||
resource app_signature "application/x-vnd.haiku.dial-up-preflet";
|
||||
resource app_signature "application/x-vnd.haiku.connect-up-preflet";
|
||||
|
||||
/* BEOS:APP_FLAGS :
|
||||
00000000 = SINGLE LAUNCH
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO:
|
||||
- finish |[ ] "Default" | interface handling
|
||||
- if no interface is default a newly created one becomes default
|
||||
*/
|
||||
|
||||
#include "DialUpView.h"
|
||||
#include "DialUpAddon.h"
|
||||
|
||||
|
@ -19,6 +25,8 @@
|
|||
|
||||
#include <Alert.h>
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Messenger.h>
|
||||
|
@ -31,6 +39,9 @@
|
|||
#include <Path.h>
|
||||
|
||||
|
||||
// GUI constants
|
||||
static const uint32 kInterfaceFieldWidth = 175;
|
||||
|
||||
// message constants
|
||||
static const uint32 kMsgCreateNew = 'NEWI';
|
||||
static const uint32 kMsgFinishCreateNew = 'FNEW';
|
||||
|
@ -44,6 +55,7 @@ static const char *kLabelInterface = "Verbindung: ";
|
|||
static const char *kLabelInterfaceName = "Verbindungs-Name: ";
|
||||
static const char *kLabelCreateNewInterface = "Neue Verbindung Erstellen";
|
||||
static const char *kLabelCreateNew = "Neu...";
|
||||
static const char *kLabelDefaultInterface = "Standard";
|
||||
static const char *kLabelDeleteCurrent = "Auswahl Löschen";
|
||||
static const char *kLabelConnect = "Verbinden";
|
||||
static const char *kLabelDisconnect = "Trennen";
|
||||
|
@ -53,6 +65,7 @@ static const char *kLabelInterface = "Interface: ";
|
|||
static const char *kLabelInterfaceName = "Interface Name: ";
|
||||
static const char *kLabelCreateNewInterface = "Create New Interface";
|
||||
static const char *kLabelCreateNew = "Create New...";
|
||||
static const char *kLabelDefaultInterface = "Default";
|
||||
static const char *kLabelDeleteCurrent = "Delete Current";
|
||||
static const char *kLabelConnect = "Connect";
|
||||
static const char *kLabelDisconnect = "Disconnect";
|
||||
|
@ -137,11 +150,17 @@ DialUpView::DialUpView(BRect frame)
|
|||
fInterfaceMenu = new BPopUpMenu(kLabelCreateNew);
|
||||
BRect rect = bounds;
|
||||
rect.InsetBy(5, 5);
|
||||
rect.right = kInterfaceFieldWidth;
|
||||
rect.bottom = rect.top + 20;
|
||||
fMenuField = new BMenuField(rect, "Interfaces", kLabelInterface, fInterfaceMenu);
|
||||
fMenuField->SetDivider(StringWidth(fMenuField->Label()) + 5);
|
||||
|
||||
rect.top = rect.bottom + 10;
|
||||
rect.top += 3;
|
||||
rect.bottom -= 2;
|
||||
rect.left = rect.right + 5;
|
||||
rect.right = bounds.right - 5;
|
||||
fDefaultInterface = new BCheckBox(rect, "Default", kLabelDefaultInterface, NULL);
|
||||
rect.left = bounds.left + 5;
|
||||
rect.top = rect.bottom + 12;
|
||||
rect.bottom = bounds.bottom
|
||||
- 20 // height of bottom controls
|
||||
- 20; // space for bottom controls
|
||||
|
@ -178,6 +197,7 @@ DialUpView::DialUpView(BRect frame)
|
|||
new BMessage(kMsgConnectButton));
|
||||
|
||||
AddChild(fMenuField);
|
||||
AddChild(fDefaultInterface);
|
||||
AddChild(fTabView);
|
||||
AddChild(fStringView);
|
||||
AddChild(fCreateNewButton);
|
||||
|
@ -229,6 +249,7 @@ DialUpView::MessageReceived(BMessage *message)
|
|||
|
||||
// -------------------------------------------------
|
||||
case kMsgCreateNew: {
|
||||
UpdateControls();
|
||||
(new TextRequestDialog(kLabelCreateNewInterface, kTextChooseInterfaceName,
|
||||
kLabelInterfaceName))->Go(
|
||||
new BInvoker(new BMessage(kMsgFinishCreateNew), this));
|
||||
|
@ -243,6 +264,8 @@ DialUpView::MessageReceived(BMessage *message)
|
|||
|
||||
if(fCurrentItem)
|
||||
fCurrentItem->SetMarked(true);
|
||||
|
||||
UpdateControls();
|
||||
} break;
|
||||
// -------------------------------------------------
|
||||
|
||||
|
@ -599,6 +622,8 @@ DialUpView::SelectInterface(int32 index, bool isNew = false)
|
|||
WatchInterface(fListener.Manager().InterfaceWithName(fCurrentItem->Label()));
|
||||
}
|
||||
|
||||
UpdateControls();
|
||||
|
||||
if(!fCurrentItem)
|
||||
fSettings.LoadSettings(NULL, false);
|
||||
// tell modules to unload all settings
|
||||
|
@ -637,4 +662,11 @@ DialUpView::UpdateControls()
|
|||
fCreateNewButton->Show();
|
||||
fConnectButton->SetEnabled(false);
|
||||
}
|
||||
|
||||
float width = fInterfaceMenu->StringWidth(fMenuField->Label())
|
||||
+ fInterfaceMenu->StringWidth(fInterfaceMenu->Superitem()->Label()) + 30;
|
||||
if(width > kInterfaceFieldWidth)
|
||||
width = kInterfaceFieldWidth;
|
||||
fDefaultInterface->MoveTo(fMenuField->Frame().left + width,
|
||||
fDefaultInterface->Frame().top);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ class DialUpView : public BView {
|
|||
BButton *fConnectButton, *fCreateNewButton;
|
||||
BPopUpMenu *fInterfaceMenu;
|
||||
BMenuField *fMenuField;
|
||||
BCheckBox *fDefaultInterface;
|
||||
BStringView *fStringView;
|
||||
// shows "No interfaces found..." notice
|
||||
BTabView *fTabView;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
Short-term TODOs:
|
||||
- add "Revert Changes" button
|
||||
- load add-ons from /boot/home/config/add-ons/DialUpPreflet
|
||||
- load add-ons from /boot/home/config/add-ons/ptp
|
||||
- move DEVNOTES into a doxygen file and document the rest of the API
|
||||
- IPCP: check for incorrect settings (only IP addresses should be entered)
|
||||
- PPPoE: refresh interfaces list every second or so
|
||||
- ConnectionOptions: add field for entering number of dial retries and delay between retries
|
||||
- ConnectionOptions: add field for entering number of connect retries and delay between retries
|
||||
|
||||
Long-term TODOs:
|
||||
- (maybe) allow selecting multiple authenticators (in expert-mode)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef _TEXT_REQUEST_DIALOG__H
|
||||
#define _TEXT_REQUEST_DIALOG__H
|
||||
#ifndef _TEXT_REQUEST_CONNECTOG__H
|
||||
#define _TEXT_REQUEST_CONNECTOG__H
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue