BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / network_settings / ipv6 / IPv6InterfaceAddOn.cpp
blob7eec1ca47b4a943080dc783d624b560e0f267cb4
1 /*
2 * Copyright 2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, <axeld@pinc-software.de>
7 */
10 #include <Catalog.h>
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 "IPv6InterfaceAddOn"
24 class IPv6InterfaceAddOn : public BNetworkSettingsAddOn {
25 public:
26 IPv6InterfaceAddOn(image_id image,
27 BNetworkSettings& settings);
28 virtual ~IPv6InterfaceAddOn();
30 virtual BNetworkSettingsInterfaceItem*
31 CreateNextInterfaceItem(uint32& cookie,
32 const char* interface);
36 class IPv6InterfaceItem : public BNetworkSettingsInterfaceItem {
37 public:
38 IPv6InterfaceItem(const char* interface,
39 BNetworkSettings& settings);
40 virtual ~IPv6InterfaceItem();
42 virtual BListItem* ListItem();
43 virtual BView* View();
45 virtual status_t Revert();
46 virtual bool IsRevertable();
48 virtual void ConfigurationUpdated(const BMessage& message);
50 private:
51 BNetworkSettings& fSettings;
52 BNetworkInterfaceListItem*
53 fItem;
54 InterfaceAddressView*
55 fView;
59 // #pragma mark -
62 IPv6InterfaceItem::IPv6InterfaceItem(const char* interface,
63 BNetworkSettings& settings)
65 BNetworkSettingsInterfaceItem(interface),
66 fSettings(settings),
67 fItem(new BNetworkInterfaceListItem(AF_INET6, Interface(),
68 B_TRANSLATE("IPv6"), settings)),
69 fView(NULL)
74 IPv6InterfaceItem::~IPv6InterfaceItem()
76 if (fView->Parent() == NULL)
77 delete fView;
79 delete fItem;
83 BListItem*
84 IPv6InterfaceItem::ListItem()
86 return fItem;
90 BView*
91 IPv6InterfaceItem::View()
93 if (fView == NULL)
94 fView = new InterfaceAddressView(AF_INET6, Interface(), fSettings);
96 return fView;
100 status_t
101 IPv6InterfaceItem::Revert()
103 return fView != NULL ? fView->Revert() : B_OK;
107 bool
108 IPv6InterfaceItem::IsRevertable()
110 return fView != NULL ? fView->IsRevertable() : false;
114 void
115 IPv6InterfaceItem::ConfigurationUpdated(const BMessage& message)
117 if (fView != NULL)
118 fView->ConfigurationUpdated(message);
122 // #pragma mark -
125 IPv6InterfaceAddOn::IPv6InterfaceAddOn(image_id image,
126 BNetworkSettings& settings)
128 BNetworkSettingsAddOn(image, settings)
133 IPv6InterfaceAddOn::~IPv6InterfaceAddOn()
138 BNetworkSettingsInterfaceItem*
139 IPv6InterfaceAddOn::CreateNextInterfaceItem(uint32& cookie,
140 const char* interface)
142 if (cookie++ == 0)
143 return new IPv6InterfaceItem(interface, Settings());
145 return NULL;
149 // #pragma mark -
152 extern "C"
153 BNetworkSettingsAddOn*
154 instantiate_network_settings_add_on(image_id image, BNetworkSettings& settings)
156 return new IPv6InterfaceAddOn(image, settings);