2 * Copyright 2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, <axeld@pinc-software.de>
11 #include <NetworkSettingsAddOn.h>
12 #include <StringItem.h>
14 #include "InterfaceAddressView.h"
17 using namespace BNetworkKit
;
20 #undef B_TRANSLATION_CONTEXT
21 #define B_TRANSLATION_CONTEXT "IPv4InterfaceAddOn"
24 class IPv4InterfaceAddOn
: public BNetworkSettingsAddOn
{
26 IPv4InterfaceAddOn(image_id image
,
27 BNetworkSettings
& settings
);
28 virtual ~IPv4InterfaceAddOn();
30 virtual BNetworkSettingsInterfaceItem
*
31 CreateNextInterfaceItem(uint32
& cookie
,
32 const char* interface
);
36 class IPv4InterfaceItem
: public BNetworkSettingsInterfaceItem
{
38 IPv4InterfaceItem(const char* interface
,
39 BNetworkSettings
& settings
);
40 virtual ~IPv4InterfaceItem();
42 virtual BListItem
* ListItem();
43 virtual BView
* View();
45 virtual status_t
Revert();
46 virtual bool IsRevertable();
48 virtual void ConfigurationUpdated(const BMessage
& message
);
51 BNetworkSettings
& fSettings
;
52 BNetworkInterfaceListItem
*
62 IPv4InterfaceItem::IPv4InterfaceItem(const char* interface
,
63 BNetworkSettings
& settings
)
65 BNetworkSettingsInterfaceItem(interface
),
67 fItem(new BNetworkInterfaceListItem(AF_INET
, Interface(),
68 B_TRANSLATE("IPv4"), settings
)),
74 IPv4InterfaceItem::~IPv4InterfaceItem()
76 if (fView
->Parent() == NULL
)
84 IPv4InterfaceItem::ListItem()
91 IPv4InterfaceItem::View()
94 fView
= new InterfaceAddressView(AF_INET
, Interface(), fSettings
);
101 IPv4InterfaceItem::Revert()
103 return fView
!= NULL
? fView
->Revert() : B_OK
;
108 IPv4InterfaceItem::IsRevertable()
110 return fView
!= NULL
? fView
->IsRevertable() : false;
115 IPv4InterfaceItem::ConfigurationUpdated(const BMessage
& message
)
118 fView
->ConfigurationUpdated(message
);
125 IPv4InterfaceAddOn::IPv4InterfaceAddOn(image_id image
,
126 BNetworkSettings
& settings
)
128 BNetworkSettingsAddOn(image
, settings
)
133 IPv4InterfaceAddOn::~IPv4InterfaceAddOn()
138 BNetworkSettingsInterfaceItem
*
139 IPv4InterfaceAddOn::CreateNextInterfaceItem(uint32
& cookie
,
140 const char* interface
)
143 return new IPv4InterfaceItem(interface
, Settings());
153 BNetworkSettingsAddOn
*
154 instantiate_network_settings_add_on(image_id image
, BNetworkSettings
& settings
)
156 return new IPv4InterfaceAddOn(image
, settings
);