2 * Copyright 2003-2004 Waldemar Kornewald. All rights reserved.
3 * Copyright 2017 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
7 //-----------------------------------------------------------------------
8 // GeneralAddon saves the loaded settings.
9 // GeneralView saves the current settings.
10 //-----------------------------------------------------------------------
12 #ifndef _GENERAL_ADDON__H
13 #define _GENERAL_ADDON__H
15 #include "DialUpAddon.h"
19 #include <TextControl.h>
27 class GeneralAddon
: public DialUpAddon
{
29 GeneralAddon(BMessage
*addons
);
30 virtual ~GeneralAddon();
35 const char *DeviceName() const
36 { return fDeviceName
.String(); }
37 const char *Username() const
38 { return fUsername
.String(); }
39 const char *Password() const
40 { return fPassword
.String(); }
41 bool HasPassword() const
42 { return fHasPassword
; }
44 bool NeedsAuthenticationRequest() const;
46 DialUpAddon
*FindDevice(const BString
& moduleName
) const;
47 DialUpAddon
*DeviceAddon() const
48 { return fDeviceAddon
; }
50 int32
CountAuthenticators() const
51 { return fAuthenticatorsCount
; }
53 BMessage
*Settings() const
55 BMessage
*Profile() const
58 virtual int32
Position() const
60 virtual bool LoadSettings(BMessage
*settings
, BMessage
*profile
, bool isNew
);
61 bool LoadDeviceSettings();
62 bool LoadAuthenticationSettings();
64 virtual bool HasTemporaryProfile() const;
65 virtual void IsModified(bool *settings
, bool *profile
) const;
66 void IsDeviceModified(bool *settings
, bool *profile
) const;
67 void IsAuthenticationModified(bool *settings
, bool *profile
) const;
69 virtual bool SaveSettings(BMessage
*settings
, BMessage
*profile
,
71 virtual bool GetPreferredSize(float *width
, float *height
) const;
72 virtual BView
*CreateView();
75 bool GetAuthenticator(const BString
& moduleName
, BMessage
*entry
) const;
76 bool MarkAuthenticatorAsValid(const BString
& moduleName
);
79 bool fIsNew
, fHasPassword
;
80 BString fDeviceName
, fUsername
, fPassword
;
81 DialUpAddon
*fDeviceAddon
;
82 int32 fAuthenticatorsCount
;
83 BMessage
*fSettings
, *fProfile
;
84 // saves last settings state
85 GeneralView
*fGeneralView
;
89 class GeneralView
: public BView
{
91 GeneralView(GeneralAddon
*addon
);
92 virtual ~GeneralView();
94 GeneralAddon
*Addon() const
98 const char *Username() const
99 { return fUsername
->Text(); }
100 const char *Password() const
101 { return fPassword
->Text(); }
102 bool DoesSavePassword() const
103 { return fSavePassword
->Value(); }
105 bool HasTemporaryProfile() const
106 { return !DoesSavePassword() || (fDeviceAddon
&&
107 fDeviceAddon
->HasTemporaryProfile()); }
109 DialUpAddon
*DeviceAddon() const
110 { return fDeviceAddon
; }
111 const char *DeviceName() const;
112 const char *AuthenticatorName() const;
113 void IsDeviceModified(bool *settings
, bool *profile
) const;
115 virtual void AttachedToWindow();
116 virtual void MessageReceived(BMessage
*message
);
119 void ReloadDeviceView();
120 void UpdateControls();
123 void AddAuthenticators();
126 GeneralAddon
*fAddon
;
127 DialUpAddon
*fDeviceAddon
;
129 BMenuField
*fDeviceField
, *fAuthenticatorField
;
130 BMenuItem
*fAuthenticatorNone
, *fAuthenticatorDefault
;
131 BTextControl
*fUsername
, *fPassword
;
132 BCheckBox
*fSavePassword
;