From 9fee39fd65bb03ebaca0f58d7b13c0ce3f8d910d Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Mon, 5 Apr 2004 08:34:07 +0000 Subject: [PATCH] Some more usability work. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7166 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../DialUpPreflet/ConnectionOptionsAddon.cpp | 15 +++--- .../kits/net/DialUpPreflet/DialUpAddon.h | 5 -- .../kits/net/DialUpPreflet/DialUpView.cpp | 32 +++++++++--- .../kits/net/DialUpPreflet/GeneralAddon.cpp | 9 ++-- .../kits/net/DialUpPreflet/IPCPAddon.cpp | 19 ++++--- src/tests/kits/net/DialUpPreflet/Jamfile | 13 +++++ .../MessageDriverSettingsUtils.cpp | 8 +-- .../kits/net/DialUpPreflet/PPPoEAddon.cpp | 16 +++--- src/tests/kits/net/DialUpPreflet/TODO | 2 +- .../net/DialUpPreflet/TextRequestDialog.cpp | 52 ++++++++++++++++--- .../net/DialUpPreflet/TextRequestDialog.h | 10 +++- 11 files changed, 127 insertions(+), 54 deletions(-) diff --git a/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp b/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp index 1f6e45ddbd..0aa1c08202 100644 --- a/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/ConnectionOptionsAddon.cpp @@ -17,16 +17,17 @@ // message constants -static const uint32 kMsgUpdateControls = 'UPDC'; +static const uint32 kMsgUpdateControls = 'UCTL'; // labels #ifdef LANG_GERMAN -static const char *kLabelConnectionOptions = "Verbindungs-Optionen"; -static const char *kLabelDialOnDemand = "Bei Bedarf Automatisch Verbinden"; +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"; #else -static const char *kLabelConnectionOptions = "Connection Options"; +static const char *kLabelConnectionOptions = "Options"; static const char *kLabelDialOnDemand = "Connect Automatically When Needed"; static const char *kLabelAskBeforeDialing = "Ask Before Dialing"; static const char *kLabelAutoRedial = "Redial Automatically"; @@ -245,10 +246,6 @@ ConnectionOptionsView::MessageReceived(BMessage *message) void ConnectionOptionsView::UpdateControls() { - if(fDialOnDemand->Value()) - fAskBeforeDialing->SetEnabled(true); - else - fAskBeforeDialing->SetEnabled(false); - + fAskBeforeDialing->SetEnabled(fDialOnDemand->Value()); fAskBeforeDialing->SetValue(fDialOnDemand->Value()); } diff --git a/src/tests/kits/net/DialUpPreflet/DialUpAddon.h b/src/tests/kits/net/DialUpPreflet/DialUpAddon.h index 35a498e3e5..d3ef461d39 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpAddon.h +++ b/src/tests/kits/net/DialUpPreflet/DialUpAddon.h @@ -18,11 +18,6 @@ #include -// ------------------------------------------- -// uncomment the language (English by default) -// #define LANG_GERMAN -// ------------------------------------------- - #define DUN_MAXIMUM_PRIORITY 50 // add-on types diff --git a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp index 68511b1d61..3e6600c553 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp +++ b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp @@ -51,7 +51,7 @@ static const uint32 kMsgConnectButton = 'CONI'; #ifdef LANG_GERMAN static const char *kLabelInterface = "Verbindung: "; static const char *kLabelInterfaceName = "Verbindungs-Name: "; -static const char *kLabelNewInterface = "Neue Verbindung"; +static const char *kLabelNewInterface = "Neue Verbindung Erstellen"; static const char *kLabelCreateNew = "Neu..."; static const char *kLabelDeleteCurrent = "Auswahl Löschen"; static const char *kLabelConnect = "Verbinden"; @@ -60,7 +60,7 @@ static const char *kLabelOK = "OK"; #else static const char *kLabelInterface = "Interface: "; static const char *kLabelInterfaceName = "Interface Name: "; -static const char *kLabelNewInterface = "New Interface"; +static const char *kLabelNewInterface = "Create New Interface"; static const char *kLabelCreateNew = "Create New..."; static const char *kLabelDeleteCurrent = "Delete Current"; static const char *kLabelConnect = "Connect"; @@ -73,20 +73,27 @@ static const char *kLabelOK = "OK"; static const char *kTextConnecting = "Verbinde..."; static const char *kTextConnectionEstablished = "Verbindung hergestellt."; static const char *kTextNotConnected = "Nicht verbunden."; +static const char *kTextDeviceUpFailed = "Konnte Verbindung nicht aufbauen."; static const char *kTextAuthenticating = "Authentifizierung..."; static const char *kTextAuthenticationFailed = "Authentifizierung fehlgeschlagen!"; static const char *kTextConnectionLost = "Verbindung verloren!"; static const char *kTextCreationError = "Fehler beim Initialisieren!"; -static const char *kTextNoInterfacesFound = "Kein Verbindungen gefunden..."; +static const char *kTextNoInterfacesFound = "Bitte erstellen Sie eine neue " + "Verbindung."; +static const char *kTextChooseInterfaceName = "Bitte denken Sie sich einen neuen " + "Namen für diese Verbindung aus."; #else static const char *kTextConnecting = "Connecting..."; static const char *kTextConnectionEstablished = "Connection established."; static const char *kTextNotConnected = "Not connected."; +static const char *kTextDeviceUpFailed = "Failed to connect."; static const char *kTextAuthenticating = "Authenticating..."; static const char *kTextAuthenticationFailed = "Authentication failed!"; static const char *kTextConnectionLost = "Connection lost!"; static const char *kTextCreationError = "Error creating interface!"; -static const char *kTextNoInterfacesFound = "No interfaces found..."; +static const char *kTextNoInterfacesFound = "Please create a new interface..."; +static const char *kTextChooseInterfaceName = "Please choose a new name for this " + "interface."; #endif // error strings for alerts @@ -230,7 +237,8 @@ DialUpView::MessageReceived(BMessage *message) // ------------------------------------------------- case kMsgCreateNew: { - (new TextRequestDialog(kLabelNewInterface, kLabelInterfaceName))->Go( + (new TextRequestDialog(kLabelNewInterface, kTextChooseInterfaceName, + kLabelInterfaceName))->Go( new BInvoker(new BMessage(kMsgFinishCreateNew), this)); } break; @@ -606,6 +614,9 @@ DialUpView::UpdateStatus(int32 code) { switch(code) { case PPP_REPORT_UP_ABORTED: + case PPP_REPORT_DEVICE_UP_FAILED: + case PPP_REPORT_LOCAL_AUTHENTICATION_FAILED: + case PPP_REPORT_PEER_AUTHENTICATION_FAILED: case PPP_REPORT_DOWN_SUCCESSFUL: case PPP_REPORT_CONNECTION_LOST: { fConnectButton->SetLabel(kLabelConnect); @@ -615,7 +626,8 @@ DialUpView::UpdateStatus(int32 code) fConnectButton->SetLabel(kLabelDisconnect); } - // maybe the information string must stay + // maybe the status string must not be changed (codes that set fKeepLabel to false + // should still be handled) if(fKeepLabel && code != PPP_REPORT_GOING_UP && code != PPP_REPORT_UP_SUCCESSFUL) return; @@ -624,6 +636,7 @@ DialUpView::UpdateStatus(int32 code) return; } + // only errors should set fKeepLabel to true switch(code) { case PPP_REPORT_GOING_UP: fKeepLabel = false; @@ -640,6 +653,11 @@ DialUpView::UpdateStatus(int32 code) fStatusView->SetText(kTextNotConnected); break; + case PPP_REPORT_DEVICE_UP_FAILED: + fKeepLabel = true; + fStatusView->SetText(kTextDeviceUpFailed); + break; + case PPP_REPORT_LOCAL_AUTHENTICATION_REQUESTED: case PPP_REPORT_PEER_AUTHENTICATION_REQUESTED: fStatusView->SetText(kTextAuthenticating); @@ -704,7 +722,7 @@ void DialUpView::LoadInterfaces() { fInterfaceMenu->AddSeparatorItem(); - fInterfaceMenu->AddItem(new BMenuItem(kLabelCreateNew, + fInterfaceMenu->AddItem(new BMenuItem(kLabelNewInterface, new BMessage(kMsgCreateNew))); fDeleterItem = new BMenuItem(kLabelDeleteCurrent, new BMessage(kMsgDeleteCurrent)); diff --git a/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp b/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp index d3796f89e2..4ae66b19c3 100644 --- a/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/GeneralAddon.cpp @@ -36,9 +36,9 @@ static const char *kLabelDevice = "Gerät: "; static const char *kLabelNoDevicesFound = "Keine Geräte Gefunden!"; static const char *kLabelAuthenticator = "Login: "; static const char *kLabelNoAuthenticatorsFound = "Keine Login-Methoden gefunden!"; -static const char *kLabelName = "Name: "; +static const char *kLabelName = "Benutzername: "; static const char *kLabelPassword = "Password: "; -static const char *kLabelSavePassword = "Password Speichern"; +static const char *kLabelSavePassword = "Passwort Speichern"; static const char *kLabelNone = "Ohne"; #else static const char *kLabelGeneral = "General"; @@ -46,7 +46,7 @@ static const char *kLabelDevice = "Device: "; static const char *kLabelNoDevicesFound = "No Devices Found!"; static const char *kLabelAuthenticator = "Login: "; static const char *kLabelNoAuthenticatorsFound = "No Authenticators Found!"; -static const char *kLabelName = "Name: "; +static const char *kLabelName = "Username: "; static const char *kLabelPassword = "Password: "; static const char *kLabelSavePassword = "Save Password"; static const char *kLabelNone = "None"; @@ -473,6 +473,7 @@ GeneralView::Reload() item = fDeviceField->Menu()->ItemAt(0); item->SetMarked(true); item->Message()->FindPointer("Addon", reinterpret_cast(&fDeviceAddon)); + fDeviceAddon->LoadSettings(Addon()->Settings(), Addon()->Profile(), true); } else { fDeviceAddon = NULL; item = fDeviceField->Menu()->FindMarked(); @@ -480,8 +481,6 @@ GeneralView::Reload() item->SetMarked(false); } - ReloadDeviceView(); - if(Addon()->CountAuthenticators() > 0) { BString kernelModule, authenticator; BMessage authentication; diff --git a/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp b/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp index f561006a50..724ac5c03b 100644 --- a/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/IPCPAddon.cpp @@ -30,18 +30,20 @@ static const uint32 kMsgUpdateControls = 'UCTL'; // labels #ifdef LANG_GERMAN static const char *kLabelIPCP = "TCP/IP"; -static const char *kLabelEnabled = "Verwenden"; static const char *kLabelIPAddress = "IP Adresse: "; static const char *kLabelPrimaryDNS = "Primärer DNS: "; static const char *kLabelSecondaryDNS = "Sekundärer DNS: "; static const char *kLabelOptional = "(Optional)"; +static const char *kLabelExtendedOptions = "Erweiterte Optionen:"; +static const char *kLabelEnabled = "TCP/IP-Protokoll Verwenden"; #else static const char *kLabelIPCP = "TCP/IP"; -static const char *kLabelEnabled = "Enabled"; static const char *kLabelIPAddress = "IP Address: "; static const char *kLabelPrimaryDNS = "Primary DNS: "; static const char *kLabelSecondaryDNS = "Secondary DNS: "; static const char *kLabelOptional = "(Optional)"; +static const char *kLabelExtendedOptions = "Extended Options:"; +static const char *kLabelEnabled = "Enable TCP/IP Protocol"; #endif // add-on descriptions @@ -277,12 +279,6 @@ IPCPView::IPCPView(IPCPAddon *addon, BRect frame) { BRect rect = Bounds(); rect.InsetBy(10, 10); - rect.bottom = rect.top + 15; - fIsEnabled = new BCheckBox(rect, "isEnabled", kLabelEnabled, - new BMessage(kMsgUpdateControls)); - rect.left += 15; - // indent the other controls to indicate that they depend on this control - rect.top = rect.bottom + 5; rect.bottom = rect.top + 20; BRect optionalRect(rect); rect.right -= 75; @@ -303,6 +299,13 @@ IPCPView::IPCPView(IPCPAddon *addon, BRect frame) optionalRect.top = rect.top; optionalRect.bottom = optionalRect.top + 15; AddChild(new BStringView(optionalRect, "optional_3", kLabelOptional)); + rect.top = rect.bottom + 50; + rect.bottom = rect.top + 10; + AddChild(new BStringView(rect, "expert", kLabelExtendedOptions)); + rect.top = rect.bottom + 5; + rect.bottom = rect.top + 15; + fIsEnabled = new BCheckBox(rect, "isEnabled", kLabelEnabled, + new BMessage(kMsgUpdateControls)); // set divider of text controls float controlWidth = max(max(StringWidth(fIPAddress->Label()), diff --git a/src/tests/kits/net/DialUpPreflet/Jamfile b/src/tests/kits/net/DialUpPreflet/Jamfile index 525fdd8586..f26b47573a 100644 --- a/src/tests/kits/net/DialUpPreflet/Jamfile +++ b/src/tests/kits/net/DialUpPreflet/Jamfile @@ -1,5 +1,18 @@ SubDir OBOS_TOP src tests kits net DialUpPreflet ; +# set some additional defines +{ + local defines ; + + if $(LANG_GERMAN) { + defines += LANG_GERMAN ; + } + + defines = [ FDefines $(defines) ] ; + SubDirCcFlags $(defines) ; + SubDirC++Flags $(defines) ; +} + UsePrivateHeaders net ; UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libppp headers ] ; UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp headers ] ; diff --git a/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp b/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp index 73ae188428..ef76fa2350 100644 --- a/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp +++ b/src/tests/kits/net/DialUpPreflet/MessageDriverSettingsUtils.cpp @@ -182,10 +182,11 @@ WriteParameter(BFile& file, const BMessage& parameter, int32 level) line << word; if(needsEscaping) line << '\"'; - line << ' '; - for(int32 index = 0; parameter.FindString(MDSU_VALUES, index, &name) == B_OK; index++) + for(int32 index = 0; parameter.FindString(MDSU_VALUES, index, &name) == B_OK; + index++) if(name) { + line << ' '; word = name; EscapeWord(word); needsEscaping = word.FindFirst(' ') >= 0; @@ -194,7 +195,6 @@ WriteParameter(BFile& file, const BMessage& parameter, int32 level) line << word; if(needsEscaping) line << '\"'; - line << ' '; } type_code type; @@ -202,7 +202,7 @@ WriteParameter(BFile& file, const BMessage& parameter, int32 level) parameter.GetInfo(MDSU_PARAMETERS, &type, ¶meterCount); if(parameterCount > 0) - line << '{'; + line << " {"; line << '\n'; file.Write(line.String(), line.Length()); diff --git a/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp b/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp index 4f55607162..5efdbfdd73 100644 --- a/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp +++ b/src/tests/kits/net/DialUpPreflet/PPPoEAddon.cpp @@ -117,11 +117,12 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew) fInterfaceName = fServiceName = ""; fSettings = settings; fProfile = profile; - if(!settings || !profile || isNew) { - if(fPPPoEView) - fPPPoEView->Reload(); + + if(fPPPoEView) + fPPPoEView->Reload(); + + if(!settings || !profile || isNew) return true; - } BMessage device; int32 deviceIndex = 0; @@ -157,6 +158,9 @@ PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew) device.AddBool(MDSU_VALID, true); fSettings->ReplaceMessage(MDSU_PARAMETERS, deviceIndex, &device); + if(fPPPoEView) + fPPPoEView->Reload(); + return true; } @@ -305,7 +309,7 @@ PPPoEView::MessageReceived(BMessage *message) } break; case kMsgSelectOther: - (new TextRequestDialog("InterfaceName", kRequestInterfaceName, + (new TextRequestDialog("InterfaceName", NULL, kRequestInterfaceName, fInterfaceName.String()))->Go(new BInvoker( new BMessage(kMsgFinishSelectOther), this)); break; @@ -378,7 +382,7 @@ PPPoEView::ReloadInterfaces() } // set interface or some default value if nothing was found - if(Addon()->InterfaceName()) + if(Addon()->InterfaceName() && strlen(Addon()->InterfaceName()) > 0) fInterfaceName = Addon()->InterfaceName(); else if(count > 0) fInterfaceName = interfaces; diff --git a/src/tests/kits/net/DialUpPreflet/TODO b/src/tests/kits/net/DialUpPreflet/TODO index 76d2b2763a..793fdb0414 100644 --- a/src/tests/kits/net/DialUpPreflet/TODO +++ b/src/tests/kits/net/DialUpPreflet/TODO @@ -4,7 +4,7 @@ Short-term TODOs: - 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 -- Extras: add field for entering number of dial retries and delay between retries +- ConnectionOptions: add field for entering number of dial retries and delay between retries Long-term TODOs: - (maybe) allow selecting multiple authenticators (in expert-mode) diff --git a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp index fb1c0f253b..5c7e328769 100644 --- a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp +++ b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.cpp @@ -10,24 +10,26 @@ #include #include +#include // GUI constants static const uint32 kWindowWidth = 250; -static const uint32 kWindowHeight = 5 + 20 + 10 + 25 + 5; +static const uint32 kWindowHeight = 10 + 20 + 10 + 25 + 5; static const BRect kWindowRect(0, 0, kWindowWidth, kWindowHeight); static const uint32 kDefaultButtonWidth = 80; // message constants -static const int32 kMsgButton = 'MBTN'; +static const uint32 kMsgButton = 'MBTN'; +static const uint32 kMsgUpdateControls = 'UCTL'; // labels static const char *kLabelOK = "OK"; static const char *kLabelCancel = "Cancel"; -TextRequestDialog::TextRequestDialog(const char *title, const char *request, - const char *text = NULL) +TextRequestDialog::TextRequestDialog(const char *title, const char *information, + const char *request, const char *text = NULL) : BWindow(kWindowRect, title, B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE, 0), fInvoker(NULL) { @@ -35,8 +37,31 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *request, BView *backgroundView = new BView(rect, "background", B_FOLLOW_ALL_SIDES, 0); backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); rect.InsetBy(5, 5); + rect.bottom = rect.top; + // init + + if(information) { + BRect textRect(rect); + textRect.OffsetTo(0, 0); + fTextView = new BTextView(rect, "TextView", textRect, B_FOLLOW_NONE, + B_WILL_DRAW); + fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fTextView->MakeSelectable(false); + fTextView->MakeEditable(false); + fTextView->SetText(information); + float textHeight = fTextView->TextHeight(0, fTextView->CountLines()); + backgroundView->ResizeBy(0, textHeight + 5); + ResizeBy(0, textHeight + 5); + fTextView->ResizeBy(0, textHeight - textRect.Height()); + rect.bottom += textHeight + 5; + backgroundView->AddChild(fTextView); + } else + fTextView = NULL; + + rect.top = rect.bottom + 5; rect.bottom = rect.top + 20; fTextControl = new BTextControl(rect, "request", request, text, NULL); + fTextControl->SetModificationMessage(new BMessage(kMsgUpdateControls)); fTextControl->SetDivider(fTextControl->StringWidth(fTextControl->Label()) + 5); if(text && strlen(text) > 0) fTextControl->TextView()->SelectAll(); @@ -46,19 +71,21 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *request, rect.left = rect.right - kDefaultButtonWidth; BMessage message(kMsgButton); message.AddInt32("which", 1); - BButton *okButton = new BButton(rect, "okButton", kLabelOK, new BMessage(message)); + fOKButton = new BButton(rect, "okButton", kLabelOK, new BMessage(message)); rect.right = rect.left - 10; rect.left = rect.right - kDefaultButtonWidth; message.ReplaceInt32("which", 0); BButton *cancelButton = new BButton(rect, "cancelButton", kLabelCancel, new BMessage(message)); - backgroundView->AddChild(okButton); backgroundView->AddChild(cancelButton); + backgroundView->AddChild(fOKButton); backgroundView->AddChild(fTextControl); AddChild(backgroundView); fTextControl->MakeFocus(true); - SetDefaultButton(okButton); + SetDefaultButton(fOKButton); + + UpdateControls(); } @@ -87,6 +114,10 @@ TextRequestDialog::MessageReceived(BMessage *message) PostMessage(B_QUIT_REQUESTED); } break; + case kMsgUpdateControls: + UpdateControls(); + break; + default: BWindow::MessageReceived(message); } @@ -109,3 +140,10 @@ TextRequestDialog::Go(BInvoker *invoker) return B_OK; } + + +void +TextRequestDialog::UpdateControls() +{ + fOKButton->SetEnabled(fTextControl->TextView()->TextLength() > 0); +} diff --git a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h index 09dc98f10e..194552e8dc 100644 --- a/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h +++ b/src/tests/kits/net/DialUpPreflet/TextRequestDialog.h @@ -13,8 +13,8 @@ class TextRequestDialog : public BWindow { public: - TextRequestDialog(const char *title, const char *request, - const char *text = NULL); + TextRequestDialog(const char *title, const char *information, + const char *request, const char *text = NULL); virtual ~TextRequestDialog(); virtual void MessageReceived(BMessage *message); @@ -23,6 +23,12 @@ class TextRequestDialog : public BWindow { status_t Go(BInvoker *invoker); private: + void UpdateControls(); + + private: + BTextView *fTextView; + // displays information text + BButton *fOKButton; BTextControl *fTextControl; BInvoker *fInvoker; };