Added doxygen comments and simplified code a bit.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Waldemar Kornewald
2004-06-01 15:10:59 +00:00
parent dcc710213d
commit 5256712211
4 changed files with 68 additions and 22 deletions
+44 -10
View File
@@ -1,12 +1,17 @@
/* /*
This software may be distributed under the OpenBeOS license. This software may be distributed under the OpenBeOS license.
Copyright (c) 2004, OpenBeOS Copyright (c) 2004, OpenBeOS
*/
/*! \class DialUpAddon
\brief Base class for DialUpPreflet add-ons.
Dial-Up add-ons must export the following function: Dial-Up add-ons must export the following function: \n
bool register(BMessage *addons); bool register(BMessage *addons) \n
You should add your DialUpAddon object to the given BMessage. \n
Most add-ons are simple pointers to a DialUpAddon object. \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 Note for tab-addons: The BView object is deleted AFTER the DialUpAddon (except you
remove and delete it in the DialUpAddon destructor). remove and delete it in the DialUpAddon destructor).
*/ */
@@ -38,39 +43,68 @@ class DialUpAddon {
friend class DialUpView; friend class DialUpView;
public: public:
//! Constructor. The BMessage is the one passed to the \c register() function.
DialUpAddon(BMessage *addons) : fAddons(addons) {} DialUpAddon(BMessage *addons) : fAddons(addons) {}
//! Destructor. Does nothing.
virtual ~DialUpAddon() {} virtual ~DialUpAddon() {}
//! Returns the BMessage object holding all add-ons.
BMessage *Addons() const BMessage *Addons() const
{ return fAddons; } { return fAddons; }
//! Returns a name readable by humans without much technical knowledge.
virtual const char *FriendlyName() const virtual const char *FriendlyName() const
{ return NULL; } { return NULL; }
//! Returns the technical name of this module.
virtual const char *TechnicalName() const virtual const char *TechnicalName() const
{ return NULL; } { return NULL; }
//! Returns the name of the associated kernel module or \c NULL.
virtual const char *KernelModuleName() const virtual const char *KernelModuleName() const
{ return NULL; } { 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 virtual int32 Position() const
{ return -1; } { 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 virtual int32 Priority() const
{ return 0; } { 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) virtual bool LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
{ return false; } { 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 virtual bool HasTemporaryProfile() const
{ return false; } { return false; }
//! Are the settings or the profile modified?
virtual void IsModified(bool *settings, bool *profile) const virtual void IsModified(bool *settings, bool *profile) const
{ *settings = *profile = false; } { *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, virtual bool SaveSettings(BMessage *settings, BMessage *profile,
bool saveTemporary) bool saveTemporary)
{ return false; } { 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 virtual bool GetPreferredSize(float *width, float *height) const
{ return false; } { 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) virtual BView *CreateView(BPoint leftTop)
{ return NULL; } { return NULL; }
@@ -51,7 +51,7 @@ static const uint32 kMsgConnectButton = 'CONI';
#ifdef LANG_GERMAN #ifdef LANG_GERMAN
static const char *kLabelInterface = "Verbindung: "; static const char *kLabelInterface = "Verbindung: ";
static const char *kLabelInterfaceName = "Verbindungs-Name: "; 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 *kLabelCreateNew = "Neu...";
static const char *kLabelDeleteCurrent = "Auswahl Löschen"; static const char *kLabelDeleteCurrent = "Auswahl Löschen";
static const char *kLabelConnect = "Verbinden"; static const char *kLabelConnect = "Verbinden";
@@ -60,7 +60,7 @@ static const char *kLabelOK = "OK";
#else #else
static const char *kLabelInterface = "Interface: "; static const char *kLabelInterface = "Interface: ";
static const char *kLabelInterfaceName = "Interface Name: "; 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 *kLabelCreateNew = "Create New...";
static const char *kLabelDeleteCurrent = "Delete Current"; static const char *kLabelDeleteCurrent = "Delete Current";
static const char *kLabelConnect = "Connect"; static const char *kLabelConnect = "Connect";
@@ -160,13 +160,21 @@ DialUpView::DialUpView(BRect frame)
tabViewRect.bottom -= fTabView->TabHeight(); tabViewRect.bottom -= fTabView->TabHeight();
fAddons.AddRect(DUN_TAB_VIEW_RECT, tabViewRect); fAddons.AddRect(DUN_TAB_VIEW_RECT, tabViewRect);
BRect stringRect(rect); BRect tmpRect(rect);
stringRect.top += (stringRect.Height() - 15) / 2; tmpRect.top += (tmpRect.Height() - 15) / 2;
stringRect.bottom = stringRect.top + 15; tmpRect.bottom = tmpRect.top + 15;
fStringView = new BStringView(stringRect, "NoInterfacesFound", fStringView = new BStringView(tmpRect, "NoInterfacesFound",
kTextNoInterfacesFound); kTextNoInterfacesFound);
fStringView->SetAlignment(B_ALIGN_CENTER); fStringView->SetAlignment(B_ALIGN_CENTER);
fStringView->Hide(); 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.top = rect.bottom + 15;
rect.bottom = rect.top + 15; rect.bottom = rect.top + 15;
@@ -182,6 +190,7 @@ DialUpView::DialUpView(BRect frame)
AddChild(fMenuField); AddChild(fMenuField);
AddChild(fTabView); AddChild(fTabView);
AddChild(fStringView); AddChild(fStringView);
AddChild(fCreateNewButton);
AddChild(fStatusView); AddChild(fStatusView);
AddChild(fConnectButton); AddChild(fConnectButton);
@@ -217,6 +226,7 @@ void
DialUpView::AttachedToWindow() DialUpView::AttachedToWindow()
{ {
fInterfaceMenu->SetTargetForItems(this); fInterfaceMenu->SetTargetForItems(this);
fCreateNewButton->SetTarget(this);
fConnectButton->SetTarget(this); fConnectButton->SetTarget(this);
if(fListener.InitCheck() != B_OK) { if(fListener.InitCheck() != B_OK) {
@@ -237,7 +247,7 @@ DialUpView::MessageReceived(BMessage *message)
// ------------------------------------------------- // -------------------------------------------------
case kMsgCreateNew: { case kMsgCreateNew: {
(new TextRequestDialog(kLabelNewInterface, kTextChooseInterfaceName, (new TextRequestDialog(kLabelCreateNewInterface, kTextChooseInterfaceName,
kLabelInterfaceName))->Go( kLabelInterfaceName))->Go(
new BInvoker(new BMessage(kMsgFinishCreateNew), this)); new BInvoker(new BMessage(kMsgFinishCreateNew), this));
} break; } break;
@@ -722,7 +732,7 @@ void
DialUpView::LoadInterfaces() DialUpView::LoadInterfaces()
{ {
fInterfaceMenu->AddSeparatorItem(); fInterfaceMenu->AddSeparatorItem();
fInterfaceMenu->AddItem(new BMenuItem(kLabelNewInterface, fInterfaceMenu->AddItem(new BMenuItem(kLabelCreateNewInterface,
new BMessage(kMsgCreateNew))); new BMessage(kMsgCreateNew)));
fDeleterItem = new BMenuItem(kLabelDeleteCurrent, fDeleterItem = new BMenuItem(kLabelDeleteCurrent,
new BMessage(kMsgDeleteCurrent)); new BMessage(kMsgDeleteCurrent));
@@ -858,6 +868,7 @@ DialUpView::UpdateControls()
if(fTabView->IsHidden() && CountInterfaces() > 0) { if(fTabView->IsHidden() && CountInterfaces() > 0) {
fInterfaceMenu->SetLabelFromMarked(true); fInterfaceMenu->SetLabelFromMarked(true);
fStringView->Hide(); fStringView->Hide();
fCreateNewButton->Hide();
fTabView->Show(); fTabView->Show();
fConnectButton->SetEnabled(true); fConnectButton->SetEnabled(true);
} else if(!fTabView->IsHidden() && CountInterfaces() == 0) { } else if(!fTabView->IsHidden() && CountInterfaces() == 0) {
@@ -866,6 +877,7 @@ DialUpView::UpdateControls()
fInterfaceMenu->Superitem()->SetLabel(kLabelCreateNew); fInterfaceMenu->Superitem()->SetLabel(kLabelCreateNew);
fTabView->Hide(); fTabView->Hide();
fStringView->Show(); fStringView->Show();
fCreateNewButton->Show();
fConnectButton->SetEnabled(false); fConnectButton->SetEnabled(false);
} }
} }
@@ -26,7 +26,7 @@ class DialUpView : public BView {
void UpDownThread(); void UpDownThread();
// used by ppp_server // used by ppp_up application
bool SelectInterfaceNamed(const char *name); bool SelectInterfaceNamed(const char *name);
BView *AuthenticationView() const; BView *AuthenticationView() const;
BView *StatusView() const; BView *StatusView() const;
@@ -69,7 +69,7 @@ class DialUpView : public BView {
GeneralAddon *fGeneralAddon; GeneralAddon *fGeneralAddon;
bool fKeepLabel; bool fKeepLabel;
BStringView *fStatusView; BStringView *fStatusView;
BButton *fConnectButton; BButton *fConnectButton, *fCreateNewButton;
BPopUpMenu *fInterfaceMenu; BPopUpMenu *fInterfaceMenu;
BMenuField *fMenuField; BMenuField *fMenuField;
BStringView *fStringView; BStringView *fStringView;
@@ -65,7 +65,7 @@ class GeneralAddon : public DialUpAddon {
virtual bool GetPreferredSize(float *width, float *height) const; virtual bool GetPreferredSize(float *width, float *height) const;
virtual BView *CreateView(BPoint leftTop); virtual BView *CreateView(BPoint leftTop);
// used by ppp_server // used by ppp_up application
BView *AuthenticationView() const; BView *AuthenticationView() const;
private: private:
@@ -112,7 +112,7 @@ class GeneralView : public BView {
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
// used by ppp_server // used by ppp_up application
BView *AuthenticationView() const BView *AuthenticationView() const
{ return fAuthenticationView; } { return fAuthenticationView; }