diff --git a/src/tests/kits/net/DialUpPreflet/DialUpAddon.h b/src/tests/kits/net/DialUpPreflet/DialUpAddon.h index d3ef461d39..5ef2db2c76 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpAddon.h +++ b/src/tests/kits/net/DialUpPreflet/DialUpAddon.h @@ -1,12 +1,17 @@ /* This software may be distributed under the OpenBeOS license. Copyright (c) 2004, OpenBeOS +*/ + +/*! \class DialUpAddon + \brief Base class for DialUpPreflet add-ons. - Dial-Up add-ons must export the following function: - bool register(BMessage *addons); - - Most add-ons are simple pointers to a DialUpAddon object. - + Dial-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 + Most add-ons are simple pointers to a DialUpAddon object. \n + \n Note for tab-addons: The BView object is deleted AFTER the DialUpAddon (except you remove and delete it in the DialUpAddon destructor). */ @@ -38,39 +43,68 @@ class DialUpAddon { friend class DialUpView; public: + //! Constructor. The BMessage is the one passed to the \c register() function. DialUpAddon(BMessage *addons) : fAddons(addons) {} + //! Destructor. Does nothing. virtual ~DialUpAddon() {} + //! Returns the BMessage object holding all add-ons. BMessage *Addons() const { return fAddons; } + //! Returns a name readable by humans without much technical knowledge. virtual const char *FriendlyName() const { return NULL; } + //! Returns the technical name of this module. virtual const char *TechnicalName() const { return NULL; } + //! Returns the name of the associated kernel module or \c NULL. virtual const char *KernelModuleName() const { return NULL; } - // the kernel module for this add-on (if needed) + //! Mostly used by tabs to describe where they should appear. virtual int32 Position() const { return -1; } - // mostly used by tabs to describe where they should appear + //! Allows setting an order in which modules are asked to add the settings. virtual int32 Priority() const { return 0; } - // allows to set order in which modules are asked to add the settings + /*! \brief Load the given settings and profile. + + \param isNew Specifies if this is a newly created interface. + + \return \c true if loading was successful or \c false otherwise. + */ virtual bool LoadSettings(BMessage *settings, BMessage *profile, bool isNew) { return false; } + /*! \brief Returns if this module has a temporary profile. + + A temporary profile is never stored on the hard-disk, but only passed + to the interface on connection. This can include passwords, for example. + */ virtual bool HasTemporaryProfile() const { return false; } + //! Are the settings or the profile modified? virtual void IsModified(bool *settings, bool *profile) const { *settings = *profile = false; } + /*! \brief Save the given settings and profile. + + \param saveTemporary Specifies if the temporary profile should be written. + + \return \c true if saving was successful or \c false otherwise. + */ virtual bool SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporary) { return false; } - // temporary settings are passwords, for example + /*! \brief Get the preferred view size. + + \return \c false if this module does not export a BView object. + */ virtual bool GetPreferredSize(float *width, float *height) const { return false; } - // if false is returned your add-on does not want to add a view + /*! \brief Returns the module's BView object. + + \param leftTop Specifies the view's left-top coordinates. + */ virtual BView *CreateView(BPoint leftTop) { return NULL; } diff --git a/src/tests/kits/net/DialUpPreflet/DialUpView.cpp b/src/tests/kits/net/DialUpPreflet/DialUpView.cpp index 3e6600c553..50239cb409 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 Erstellen"; +static const char *kLabelCreateNewInterface = "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 = "Create New Interface"; +static const char *kLabelCreateNewInterface = "Create New Interface"; static const char *kLabelCreateNew = "Create New..."; static const char *kLabelDeleteCurrent = "Delete Current"; static const char *kLabelConnect = "Connect"; @@ -160,13 +160,21 @@ DialUpView::DialUpView(BRect frame) tabViewRect.bottom -= fTabView->TabHeight(); fAddons.AddRect(DUN_TAB_VIEW_RECT, tabViewRect); - BRect stringRect(rect); - stringRect.top += (stringRect.Height() - 15) / 2; - stringRect.bottom = stringRect.top + 15; - fStringView = new BStringView(stringRect, "NoInterfacesFound", + BRect tmpRect(rect); + tmpRect.top += (tmpRect.Height() - 15) / 2; + tmpRect.bottom = tmpRect.top + 15; + fStringView = new BStringView(tmpRect, "NoInterfacesFound", kTextNoInterfacesFound); fStringView->SetAlignment(B_ALIGN_CENTER); fStringView->Hide(); + tmpRect.top = tmpRect.bottom + 10; + tmpRect.bottom = tmpRect.top + 25; + fCreateNewButton = new BButton(tmpRect, "CreateNewButton", + kLabelCreateNewInterface, new BMessage(kMsgCreateNew)); + fCreateNewButton->ResizeToPreferred(); + tmpRect.left = (rect.Width() - fCreateNewButton->Bounds().Width()) / 2 + rect.left; + fCreateNewButton->MoveTo(tmpRect.left, tmpRect.top); + fCreateNewButton->Hide(); rect.top = rect.bottom + 15; rect.bottom = rect.top + 15; @@ -182,6 +190,7 @@ DialUpView::DialUpView(BRect frame) AddChild(fMenuField); AddChild(fTabView); AddChild(fStringView); + AddChild(fCreateNewButton); AddChild(fStatusView); AddChild(fConnectButton); @@ -217,6 +226,7 @@ void DialUpView::AttachedToWindow() { fInterfaceMenu->SetTargetForItems(this); + fCreateNewButton->SetTarget(this); fConnectButton->SetTarget(this); if(fListener.InitCheck() != B_OK) { @@ -237,7 +247,7 @@ DialUpView::MessageReceived(BMessage *message) // ------------------------------------------------- case kMsgCreateNew: { - (new TextRequestDialog(kLabelNewInterface, kTextChooseInterfaceName, + (new TextRequestDialog(kLabelCreateNewInterface, kTextChooseInterfaceName, kLabelInterfaceName))->Go( new BInvoker(new BMessage(kMsgFinishCreateNew), this)); } break; @@ -722,7 +732,7 @@ void DialUpView::LoadInterfaces() { fInterfaceMenu->AddSeparatorItem(); - fInterfaceMenu->AddItem(new BMenuItem(kLabelNewInterface, + fInterfaceMenu->AddItem(new BMenuItem(kLabelCreateNewInterface, new BMessage(kMsgCreateNew))); fDeleterItem = new BMenuItem(kLabelDeleteCurrent, new BMessage(kMsgDeleteCurrent)); @@ -858,6 +868,7 @@ DialUpView::UpdateControls() if(fTabView->IsHidden() && CountInterfaces() > 0) { fInterfaceMenu->SetLabelFromMarked(true); fStringView->Hide(); + fCreateNewButton->Hide(); fTabView->Show(); fConnectButton->SetEnabled(true); } else if(!fTabView->IsHidden() && CountInterfaces() == 0) { @@ -866,6 +877,7 @@ DialUpView::UpdateControls() fInterfaceMenu->Superitem()->SetLabel(kLabelCreateNew); fTabView->Hide(); fStringView->Show(); + fCreateNewButton->Show(); fConnectButton->SetEnabled(false); } } diff --git a/src/tests/kits/net/DialUpPreflet/DialUpView.h b/src/tests/kits/net/DialUpPreflet/DialUpView.h index 836ae58ad2..272667a1cc 100644 --- a/src/tests/kits/net/DialUpPreflet/DialUpView.h +++ b/src/tests/kits/net/DialUpPreflet/DialUpView.h @@ -26,7 +26,7 @@ class DialUpView : public BView { void UpDownThread(); - // used by ppp_server + // used by ppp_up application bool SelectInterfaceNamed(const char *name); BView *AuthenticationView() const; BView *StatusView() const; @@ -69,7 +69,7 @@ class DialUpView : public BView { GeneralAddon *fGeneralAddon; bool fKeepLabel; BStringView *fStatusView; - BButton *fConnectButton; + BButton *fConnectButton, *fCreateNewButton; BPopUpMenu *fInterfaceMenu; BMenuField *fMenuField; BStringView *fStringView; diff --git a/src/tests/kits/net/DialUpPreflet/GeneralAddon.h b/src/tests/kits/net/DialUpPreflet/GeneralAddon.h index cd9f0ac3e3..b278ef3ad2 100644 --- a/src/tests/kits/net/DialUpPreflet/GeneralAddon.h +++ b/src/tests/kits/net/DialUpPreflet/GeneralAddon.h @@ -65,7 +65,7 @@ class GeneralAddon : public DialUpAddon { virtual bool GetPreferredSize(float *width, float *height) const; virtual BView *CreateView(BPoint leftTop); - // used by ppp_server + // used by ppp_up application BView *AuthenticationView() const; private: @@ -112,7 +112,7 @@ class GeneralView : public BView { virtual void AttachedToWindow(); virtual void MessageReceived(BMessage *message); - // used by ppp_server + // used by ppp_up application BView *AuthenticationView() const { return fAuthenticationView; }