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