BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / network_settings / dialup / AddOn.cpp
blob4cf6fb56ae0f1c32c1b43c98fad7d0227a45eca8
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 */
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
12 #include <dirent.h>
13 #include <sys/stat.h>
15 #include <String.h>
16 #include <ListView.h>
17 #include <ListItem.h>
18 #include <ScrollView.h>
19 #include <Box.h>
20 #include <Button.h>
21 #include <Bitmap.h>
22 #include <Alert.h>
24 #include <NetworkSettings.h>
25 #include <NetworkSettingsAddOn.h>
26 #include "InterfaceListItem.h"
28 #include "DialUpView.h"
31 using namespace BNetworkKit;
34 class AddOn : public BNetworkSettingsAddOn {
35 public:
36 AddOn(image_id addon_image, BNetworkSettings& settings);
37 virtual ~AddOn();
39 virtual BNetworkSettingsItem*
40 CreateNextItem(uint32& cookie);
44 class DialUpInterfaceItem : public BNetworkSettingsItem {
45 public:
46 DialUpInterfaceItem(BNetworkSettings& settings);
47 virtual ~DialUpInterfaceItem();
49 virtual BNetworkSettingsType
50 Type() const;
52 virtual BListItem* ListItem();
53 virtual BView* View();
55 virtual status_t Revert();
56 virtual bool IsRevertable();
58 private:
59 BNetworkSettings& fSettings;
60 BListItem* fItem;
61 BView* fView;
65 // #pragma mark -
68 DialUpInterfaceItem::DialUpInterfaceItem(BNetworkSettings& settings)
70 fSettings(settings),
71 fItem(new InterfaceListItem("Dialup",
72 B_NETWORK_INTERFACE_TYPE_DIAL_UP)),
73 fView(NULL)
78 DialUpInterfaceItem::~DialUpInterfaceItem()
80 if (fView->Parent() == NULL)
81 delete fView;
83 delete fItem;
87 BNetworkSettingsType
88 DialUpInterfaceItem::Type() const
90 return B_NETWORK_SETTINGS_TYPE_DIAL_UP;
94 BListItem*
95 DialUpInterfaceItem::ListItem()
97 return fItem;
101 BView*
102 DialUpInterfaceItem::View()
104 if (fView == NULL)
105 fView = new DialUpView(/*fSettings*/);
107 return fView;
111 status_t
112 DialUpInterfaceItem::Revert()
114 return B_OK;
117 bool
118 DialUpInterfaceItem::IsRevertable()
120 // TODO
121 return false;
125 // #pragma mark -
128 AddOn::AddOn(image_id image, BNetworkSettings& settings)
129 : BNetworkSettingsAddOn(image, settings)
134 AddOn::~AddOn()
139 BNetworkSettingsItem*
140 AddOn::CreateNextItem(uint32& cookie)
142 if (cookie++ == 0)
143 return new DialUpInterfaceItem(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 AddOn(image, settings);