vfs: check userland buffers before reading them.
[haiku.git] / headers / os / add-ons / network_settings / NetworkSettingsAddOn.h
blobebcc331e4048b9ef0c1631b401a55874fa77037b
1 /*
2 * Copyright 2004-2015 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 */
6 #ifndef _NETWORK_SETTINGS_ADD_ON_H
7 #define _NETWORK_SETTINGS_ADD_ON_H
10 #include <image.h>
11 #include <ListItem.h>
12 #include <Resources.h>
13 #include <String.h>
14 #include <View.h>
17 class BNetworkAddress;
20 namespace BNetworkKit {
23 enum BNetworkSettingsType {
24 B_NETWORK_SETTINGS_TYPE_INTERFACE = 'intf',
25 B_NETWORK_SETTINGS_TYPE_SERVICE = 'serv',
26 B_NETWORK_SETTINGS_TYPE_DIAL_UP = 'dial',
27 B_NETWORK_SETTINGS_TYPE_VPN = 'vpnc',
28 B_NETWORK_SETTINGS_TYPE_OTHER = 'othr'
31 class BNetworkProfile;
32 class BNetworkSettings;
35 class BNetworkConfigurationListener {
36 public:
37 virtual void ConfigurationUpdated(
38 const BMessage& message) = 0;
42 class BNetworkSettingsListener {
43 public:
44 virtual void SettingsUpdated(uint32 type) = 0;
48 class BNetworkSettingsItem : public BNetworkConfigurationListener,
49 BNetworkSettingsListener {
50 public:
51 BNetworkSettingsItem();
52 virtual ~BNetworkSettingsItem();
54 virtual BNetworkSettingsType
55 Type() const = 0;
56 virtual BListItem* ListItem() = 0;
57 virtual BView* View() = 0;
59 virtual status_t ProfileChanged(
60 const BNetworkProfile* newProfile);
61 const BNetworkProfile*
62 Profile() const;
64 virtual status_t Revert() = 0;
65 virtual bool IsRevertable() = 0;
67 virtual void SettingsUpdated(uint32 type);
68 virtual void ConfigurationUpdated(const BMessage& message);
70 virtual void NotifySettingsUpdated();
72 private:
73 const BNetworkProfile*
74 fProfile;
78 class BNetworkSettingsInterfaceItem : public BNetworkSettingsItem {
79 public:
80 BNetworkSettingsInterfaceItem(
81 const char* interface);
82 virtual ~BNetworkSettingsInterfaceItem();
84 virtual BNetworkSettingsType
85 Type() const;
86 const char* Interface() const;
88 private:
89 const char* fInterface;
93 class BNetworkInterfaceListItem : public BListItem,
94 public BNetworkConfigurationListener {
95 public:
96 BNetworkInterfaceListItem(int family,
97 const char* interface, const char* label,
98 BNetworkSettings& settings);
99 ~BNetworkInterfaceListItem();
101 const char* Label() const;
103 virtual void DrawItem(BView* owner,
104 BRect bounds, bool complete);
105 virtual void Update(BView* owner, const BFont* font);
107 virtual void ConfigurationUpdated(const BMessage& message);
109 private:
110 BFont _AddressFont();
111 void _UpdateState();
113 private:
114 BNetworkSettings& fSettings;
115 int fFamily;
116 const char* fInterface;
117 const char* fLabel;
118 BString fAddress;
119 bool fDisabled;
120 float fLineOffset;
121 float fSpacing;
125 class BNetworkSettingsAddOn {
126 public:
127 BNetworkSettingsAddOn(image_id image,
128 BNetworkSettings& settings);
129 virtual ~BNetworkSettingsAddOn();
131 virtual BNetworkSettingsInterfaceItem*
132 CreateNextInterfaceItem(uint32& cookie,
133 const char* interface);
134 virtual BNetworkSettingsItem*
135 CreateNextItem(uint32& cookie);
137 image_id Image();
138 BResources* Resources();
139 BNetworkSettings& Settings();
141 private:
142 image_id fImage;
143 BResources* fResources;
144 BNetworkSettings& fSettings;
148 // Your add-on needs to export this hook in order to be picked up
149 extern "C" BNetworkSettingsAddOn* instantiate_network_settings_add_on(
150 image_id image, BNetworkSettings& settings);
153 } // namespace BNetworkKit
156 #endif // _NETWORK_SETTINGS_ADD_ON_H