NetworkSettingsAddOn.h revision 07addd7e
1/*
2 * Copyright 2004-2015 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 */
6#ifndef _NETWORK_SETTINGS_ADD_ON_H
7#define _NETWORK_SETTINGS_ADD_ON_H
8
9
10#include <image.h>
11#include <ListItem.h>
12#include <Resources.h>
13#include <View.h>
14
15
16namespace BNetworkKit {
17
18
19enum BNetworkSettingsType {
20	B_NETWORK_SETTINGS_TYPE_INTERFACE = 'intf',
21	B_NETWORK_SETTINGS_TYPE_SERVICE = 'serv',
22	B_NETWORK_SETTINGS_TYPE_DIAL_UP = 'dial',
23	B_NETWORK_SETTINGS_TYPE_OTHER = 'othr'
24};
25
26enum {
27	kMsgSettingsItemUpdated = 'SIup'
28};
29
30class BNetworkProfile;
31class BNetworkSettings;
32
33
34class BNetworkSettingsItem {
35public:
36								BNetworkSettingsItem();
37	virtual						~BNetworkSettingsItem();
38
39	virtual	BNetworkSettingsType
40								Type() const = 0;
41	virtual BListItem*			ListItem() = 0;
42	virtual BView*				View() = 0;
43
44	virtual status_t			ProfileChanged(
45									const BNetworkProfile* newProfile);
46			const BNetworkProfile*
47								Profile() const;
48
49	virtual	status_t			Revert() = 0;
50	virtual bool				IsRevertable() = 0;
51
52	virtual void				SettingsUpdated(uint32 type);
53	virtual void				ConfigurationUpdated(const BMessage& message);
54
55private:
56			const BNetworkProfile*
57								fProfile;
58};
59
60
61class BNetworkSettingsInterfaceItem : public BNetworkSettingsItem {
62public:
63								BNetworkSettingsInterfaceItem(
64									const char* interface);
65	virtual						~BNetworkSettingsInterfaceItem();
66
67	virtual	BNetworkSettingsType
68								Type() const;
69			const char*			Interface() const;
70
71private:
72			const char*			fInterface;
73};
74
75
76class BNetworkSettingsAddOn {
77public:
78								BNetworkSettingsAddOn(image_id image,
79									BNetworkSettings& settings);
80	virtual						~BNetworkSettingsAddOn();
81
82	virtual	BNetworkSettingsInterfaceItem*
83								CreateNextInterfaceItem(uint32& cookie,
84									const char* interface);
85	virtual	BNetworkSettingsItem*
86								CreateNextItem(uint32& cookie);
87
88			image_id			Image();
89			BResources*			Resources();
90			BNetworkSettings&	Settings();
91
92private:
93			image_id			fImage;
94			BResources*			fResources;
95			BNetworkSettings&	fSettings;
96};
97
98
99// Your add-on needs to export this hook in order to be picked up
100extern "C" BNetworkSettingsAddOn* instantiate_network_settings_add_on(
101	image_id image, BNetworkSettings& settings);
102
103
104}	// namespace BNetworkKit
105
106
107#endif // _NETWORK_SETTINGS_ADD_ON_H
108