1/*
2 * Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
3 * Distributed under the terms of the MIT License.
4 */
5
6//-----------------------------------------------------------------------
7// IPCPAddon saves the loaded settings.
8// IPCPView saves the current settings.
9//-----------------------------------------------------------------------
10
11#ifndef _IPCP_ADDON__H
12#define _IPCP_ADDON__H
13
14#include <DialUpAddon.h>
15
16#include <CheckBox.h>
17#include <String.h>
18#include <TextControl.h>
19
20class IPCPView;
21
22
23class IPCPAddon : public DialUpAddon {
24	public:
25		IPCPAddon(BMessage *addons);
26		virtual ~IPCPAddon();
27
28		bool IsNew() const
29			{ return fIsNew; }
30
31		bool IsEnabled() const
32			{ return fIsEnabled; }
33		const char *IPAddress() const
34			{ return fIPAddress.String(); }
35		const char *PrimaryDNS() const
36			{ return fPrimaryDNS.String(); }
37		const char *SecondaryDNS() const
38			{ return fSecondaryDNS.String(); }
39
40		BMessage *Settings() const
41			{ return fSettings; }
42
43		virtual int32 Position() const
44			{ return 10; }
45
46		virtual bool LoadSettings(BMessage *settings, bool isNew);
47		virtual void IsModified(bool *settings) const;
48		virtual bool SaveSettings(BMessage *settings);
49		virtual bool GetPreferredSize(float *width, float *height) const;
50		virtual BView *CreateView(BPoint leftTop);
51
52	private:
53		int32 FindIPCPProtocol(const BMessage& message, BMessage *protocol) const;
54
55	private:
56		bool fIsNew, fIsEnabled, fDeleteView;
57		BString fIPAddress, fPrimaryDNS, fSecondaryDNS;
58		BMessage *fSettings;
59			// saves last settings state
60		IPCPView *fIPCPView;
61};
62
63
64class IPCPView : public BView {
65	public:
66		IPCPView(IPCPAddon *addon, BRect frame);
67
68		IPCPAddon *Addon() const
69			{ return fAddon; }
70		void Reload();
71
72		bool IsEnabled() const
73			{ return fIsEnabled->Value(); }
74		const char *IPAddress() const
75			{ return fIPAddress->Text(); }
76		const char *PrimaryDNS() const
77			{ return fPrimaryDNS->Text(); }
78		const char *SecondaryDNS() const
79			{ return fSecondaryDNS->Text(); }
80
81		virtual void AttachedToWindow();
82		virtual void MessageReceived(BMessage *message);
83
84	private:
85		void UpdateControls();
86
87	private:
88		IPCPAddon *fAddon;
89		BCheckBox *fIsEnabled;
90		BButton *fCancelButton, *fOKButton;
91		BTextControl *fIPAddress, *fPrimaryDNS, *fSecondaryDNS;
92};
93
94
95#endif
96