xref: /haiku/src/preferences/network/InterfaceAddressView.h (revision 4bd0c1066b227cec4b79883bdef697c7a27f2e90)
1 /*
2  * Copyright 2004-2015 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Alexander von Gluck, kallisti5@unixzen.com
7  *		John Scipione, jscipione@gmail.com
8  */
9 #ifndef INTERFACE_ADDRESS_VIEW_H
10 #define INTERFACE_ADDRESS_VIEW_H
11 
12 
13 #include <GroupView.h>
14 #include <NetworkInterface.h>
15 #include <NetworkSettings.h>
16 #include <NetworkSettingsAddOn.h>
17 
18 
19 class BButton;
20 class BMenuField;
21 class BMessage;
22 class BPopUpMenu;
23 class BRect;
24 class BTextControl;
25 class IPAddressControl;
26 
27 
28 using namespace BNetworkKit;
29 
30 
31 class InterfaceAddressView : public BGroupView {
32 public:
33 								InterfaceAddressView(int family,
34 									const char* interface,
35 									BNetworkSettings& settings);
36 	virtual						~InterfaceAddressView();
37 
38 	virtual void				AttachedToWindow();
39 	virtual	void				MessageReceived(BMessage* message);
40 
41 			status_t			Revert();
42 			bool				IsRevertable() const;
43 
44 			void				ConfigurationUpdated(const BMessage& message);
45 
46 private:
47 			void				_EnableFields(bool enable);
48 			void				_UpdateFields();
49 			void				_SetModeField(uint32 mode);
50 			void				_UpdateSettings();
51 			uint32				_Mode() const;
52 
53 			void				_ConfigureAddress(
54 									BNetworkInterfaceAddressSettings& address);
55 			void				_SetAddress(BNetworkAddress& address,
56 									const char* text);
57 
58 private:
59 			int					fFamily;
60 			BNetworkInterface	fInterface;
61 			BNetworkSettings&	fSettings;
62 			uint32				fLastMode;
63 
64 			BMessage			fOriginalSettings;
65 
66 			BPopUpMenu*			fModePopUpMenu;
67 			BMenuField*			fModeField;
68 			IPAddressControl*	fAddressField;
69 			IPAddressControl*	fNetmaskField;
70 			IPAddressControl*	fGatewayField;
71 			BButton*			fApplyButton;
72 };
73 
74 
75 #endif // INTERFACE_ADDRESS_VIEW_H
76