BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / network_settings / dialup / GeneralAddon.h
blob611b41ecd9f1c8d78bdc39e387704db5551b5e79
1 /*
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.
5 */
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"
17 #include <CheckBox.h>
18 #include <String.h>
19 #include <TextControl.h>
21 class BBox;
22 class BMenuField;
23 class BMenuItem;
24 class GeneralView;
27 class GeneralAddon : public DialUpAddon {
28 public:
29 GeneralAddon(BMessage *addons);
30 virtual ~GeneralAddon();
32 bool IsNew() const
33 { return fIsNew; }
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
54 { return fSettings; }
55 BMessage *Profile() const
56 { return fProfile; }
58 virtual int32 Position() const
59 { return 0; }
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,
70 bool saveTemporary);
71 virtual bool GetPreferredSize(float *width, float *height) const;
72 virtual BView *CreateView();
74 private:
75 bool GetAuthenticator(const BString& moduleName, BMessage *entry) const;
76 bool MarkAuthenticatorAsValid(const BString& moduleName);
78 private:
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 {
90 public:
91 GeneralView(GeneralAddon *addon);
92 virtual ~GeneralView();
94 GeneralAddon *Addon() const
95 { return fAddon; }
96 void Reload();
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);
118 private:
119 void ReloadDeviceView();
120 void UpdateControls();
122 void AddDevices();
123 void AddAuthenticators();
125 private:
126 GeneralAddon *fAddon;
127 DialUpAddon *fDeviceAddon;
128 BBox *fDeviceBox;
129 BMenuField *fDeviceField, *fAuthenticatorField;
130 BMenuItem *fAuthenticatorNone, *fAuthenticatorDefault;
131 BTextControl *fUsername, *fPassword;
132 BCheckBox *fSavePassword;
136 #endif