xref: /haiku/src/add-ons/network_settings/dialup/ConnectionOptionsAddon.h (revision b31cb92f29fe89eaca84d173d0f70d38bf0c6a3d)
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  */
6 
7 //-----------------------------------------------------------------------
8 // ConnectionOptionsAddon saves the loaded settings.
9 // ConnectionOptionsView saves the current settings.
10 //-----------------------------------------------------------------------
11 
12 #ifndef _CONNECTION_OPTIONS_ADDON__H
13 #define _CONNECTION_OPTIONS_ADDON__H
14 
15 #include "DialUpAddon.h"
16 
17 #include <CheckBox.h>
18 #include <RadioButton.h>
19 
20 class ConnectionOptionsView;
21 
22 
23 class ConnectionOptionsAddon : public DialUpAddon {
24 	public:
25 		ConnectionOptionsAddon(BMessage *addons);
26 		virtual ~ConnectionOptionsAddon();
27 
28 		bool IsNew() const
29 			{ return fIsNew; }
30 
31 		bool DoesDialOnDemand() const
32 			{ return fDoesDialOnDemand; }
33 		bool AskBeforeDialing() const
34 			{ return fAskBeforeDialing; }
35 		bool DoesAutoRedial() const
36 			{ return fDoesAutoRedial; }
37 
38 		BMessage *Settings() const
39 			{ return fSettings; }
40 		BMessage *Profile() const
41 			{ return fProfile; }
42 
43 		virtual int32 Position() const
44 			{ return 50; }
45 		virtual bool LoadSettings(BMessage *settings, BMessage *profile, bool isNew);
46 		virtual void IsModified(bool *settings, bool *profile) const;
47 		virtual bool SaveSettings(BMessage *settings, BMessage *profile,
48 			bool saveTemporary);
49 		virtual bool GetPreferredSize(float *width, float *height) const;
50 		virtual BView *CreateView();
51 
52 	private:
53 		bool fIsNew;
54 		bool fDoesDialOnDemand, fAskBeforeDialing, fDoesAutoRedial;
55 		BMessage *fSettings, *fProfile;
56 			// saves last settings state
57 		ConnectionOptionsView *fConnectionOptionsView;
58 };
59 
60 
61 class ConnectionOptionsView : public BView {
62 	public:
63 		ConnectionOptionsView(ConnectionOptionsAddon *addon);
64 
65 		ConnectionOptionsAddon *Addon() const
66 			{ return fAddon; }
67 		void Reload();
68 
69 		bool DoesDialOnDemand() const
70 			{ return fDialOnDemand->Value(); }
71 		bool AskBeforeDialing() const
72 			{ return fAskBeforeDialing->Value(); }
73 		bool DoesAutoRedial() const
74 			{ return fAutoRedial->Value(); }
75 
76 		virtual void AttachedToWindow();
77 		virtual void MessageReceived(BMessage *message);
78 
79 	private:
80 		void UpdateControls();
81 
82 	private:
83 		ConnectionOptionsAddon *fAddon;
84 		BCheckBox *fDialOnDemand, *fAskBeforeDialing, *fAutoRedial;
85 };
86 
87 
88 #endif
89