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// PPPoEAddon saves the loaded settings.
9// PPPoEView saves the current settings.
10//-----------------------------------------------------------------------
11
12#ifndef _PPPoE_ADDON__H
13#define _PPPoE_ADDON__H
14
15#include "DialUpAddon.h"
16
17#include <String.h>
18#include <TextControl.h>
19
20class BMenuField;
21class BMenuItem;
22class PPPoEView;
23
24
25class PPPoEAddon : public DialUpAddon {
26	public:
27		PPPoEAddon(BMessage *addons);
28		virtual ~PPPoEAddon();
29
30		bool IsNew() const
31			{ return fIsNew; }
32
33		const char *InterfaceName() const
34			{ return fInterfaceName.String(); }
35		const char *ServiceName() const
36			{ return fServiceName.String(); }
37
38		BMessage *Settings() const
39			{ return fSettings; }
40		BMessage *Profile() const
41			{ return fProfile; }
42
43		virtual const char *FriendlyName() const;
44		virtual const char *TechnicalName() const;
45		virtual const char *KernelModuleName() const;
46
47		virtual bool LoadSettings(BMessage *settings, BMessage *profile, bool isNew);
48
49		virtual void IsModified(bool *settings, bool *profile) const;
50
51		virtual bool SaveSettings(BMessage *settings, BMessage *profile,
52			bool saveTemporary);
53		virtual bool GetPreferredSize(float *width, float *height) const;
54		virtual BView *CreateView();
55
56		void UnregisterView()
57			{ fPPPoEView = NULL; }
58
59	private:
60		bool fIsNew;
61		BString fInterfaceName, fServiceName;
62		BMessage *fSettings, *fProfile;
63			// saves last settings state
64		PPPoEView *fPPPoEView;
65		float fHeight;
66			// height of PPPoEView
67};
68
69
70class PPPoEView : public BView {
71	public:
72		PPPoEView(PPPoEAddon *addon, BRect frame);
73		virtual ~PPPoEView();
74
75		PPPoEAddon *Addon() const
76			{ return fAddon; }
77		void Reload();
78
79		const char *InterfaceName() const
80			{ return fInterfaceName.String(); }
81		const char *ServiceName() const
82			{ return fServiceName->Text(); }
83
84		virtual void AttachedToWindow();
85		virtual void MessageReceived(BMessage *message);
86
87	private:
88		void ReloadInterfaces();
89
90	private:
91		PPPoEAddon *fAddon;
92		BMenuField *fInterface;
93		BMenuItem *fOtherInterface;
94		BString fInterfaceName;
95		BTextControl *fServiceName;
96};
97
98
99#endif
100