xref: /haiku/src/add-ons/network_settings/dialup/IPCPAddon.h (revision 0fb349bc5d470bc4c826cb401f7a5e296dcca110)
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 // IPCPAddon saves the loaded settings.
9 // IPCPView saves the current settings.
10 //-----------------------------------------------------------------------
11 
12 #ifndef _IPCP_ADDON__H
13 #define _IPCP_ADDON__H
14 
15 #include "DialUpAddon.h"
16 
17 #include <CheckBox.h>
18 #include <String.h>
19 #include <TextControl.h>
20 
21 class BButton;
22 class IPCPView;
23 
24 
25 class IPCPAddon : public DialUpAddon {
26 	public:
27 		IPCPAddon(BMessage *addons);
28 		virtual ~IPCPAddon();
29 
IsNew()30 		bool IsNew() const
31 			{ return fIsNew; }
32 
IsEnabled()33 		bool IsEnabled() const
34 			{ return fIsEnabled; }
IPAddress()35 		const char *IPAddress() const
36 			{ return fIPAddress.String(); }
PrimaryDNS()37 		const char *PrimaryDNS() const
38 			{ return fPrimaryDNS.String(); }
SecondaryDNS()39 		const char *SecondaryDNS() const
40 			{ return fSecondaryDNS.String(); }
41 
Settings()42 		BMessage *Settings() const
43 			{ return fSettings; }
Profile()44 		BMessage *Profile() const
45 			{ return fProfile; }
46 
Position()47 		virtual int32 Position() const
48 			{ return 10; }
49 
50 		virtual bool LoadSettings(BMessage *settings, BMessage *profile, bool isNew);
51 		virtual void IsModified(bool *settings, bool *profile) const;
52 		virtual bool SaveSettings(BMessage *settings, BMessage *profile,
53 			bool saveTemporary);
54 		virtual bool GetPreferredSize(float *width, float *height) const;
55 		virtual BView *CreateView();
56 
57 	private:
58 		int32 FindIPCPProtocol(const BMessage& message, BMessage *protocol) const;
59 
60 	private:
61 		bool fIsNew, fIsEnabled;
62 		BString fIPAddress, fPrimaryDNS, fSecondaryDNS;
63 		BMessage *fSettings, *fProfile;
64 			// saves last settings state
65 		IPCPView *fIPCPView;
66 };
67 
68 
69 class IPCPView : public BView {
70 	public:
71 		IPCPView(IPCPAddon *addon);
72 
Addon()73 		IPCPAddon *Addon() const
74 			{ return fAddon; }
75 		void Reload();
76 
IsEnabled()77 		bool IsEnabled() const
78 			{ return fIsEnabled->Value(); }
IPAddress()79 		const char *IPAddress() const
80 			{ return fIPAddress->Text(); }
PrimaryDNS()81 		const char *PrimaryDNS() const
82 			{ return fPrimaryDNS->Text(); }
SecondaryDNS()83 		const char *SecondaryDNS() const
84 			{ return fSecondaryDNS->Text(); }
85 
86 		virtual void AttachedToWindow();
87 		virtual void MessageReceived(BMessage *message);
88 
89 	private:
90 		void UpdateControls();
91 
92 	private:
93 		IPCPAddon *fAddon;
94 		BCheckBox *fIsEnabled;
95 		BButton *fCancelButton, *fOKButton;
96 		BTextControl *fIPAddress, *fPrimaryDNS, *fSecondaryDNS;
97 };
98 
99 
100 #endif
101