1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2014 Red Hat, Inc.
*/
#ifndef NM_DEVICE_FACTORY_H
#define NM_DEVICE_FACTORY_H
#include <glib.h>
#include <glib-object.h>
#include "NetworkManager.h"
#include "nm-platform.h"
#include "nm-device.h"
/* WARNING: this file is private API between NetworkManager and its internal
* device plugins. Its API can change at any time and is not guaranteed to be
* stable. NM and device plugins are distributed together and this API is
* not meant to enable third-party plugins.
*/
typedef struct _NMDeviceFactory NMDeviceFactory;
/**
* nm_device_factory_create:
* @error: an error if creation of the factory failed, or %NULL
*
* Creates a #GObject that implements the #NMDeviceFactory interface. This
* function must not emit any signals or perform any actions that would cause
* devices or components to be created immediately. Instead these should be
* deferred to an idle handler.
*
* Returns: the #GObject implementing #NMDeviceFactory or %NULL
*/
NMDeviceFactory *nm_device_factory_create (GError **error);
/* Should match nm_device_factory_create() */
typedef NMDeviceFactory * (*NMDeviceFactoryCreateFunc) (GError **error);
/**
* nm_device_factory_get_device_type:
*
* Returns: the #NMDeviceType that this plugin creates
*/
NMDeviceType nm_device_factory_get_device_type (void);
/* Should match nm_device_factory_get_device_type() */
typedef NMDeviceType (*NMDeviceFactoryDeviceTypeFunc) (void);
/********************************************************************/
#define NM_TYPE_DEVICE_FACTORY (nm_device_factory_get_type ())
#define NM_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory))
#define NM_IS_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_FACTORY))
#define NM_DEVICE_FACTORY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory))
/* signals */
#define NM_DEVICE_FACTORY_COMPONENT_ADDED "component-added"
#define NM_DEVICE_FACTORY_DEVICE_ADDED "device-added"
struct _NMDeviceFactory {
GTypeInterface g_iface;
/**
* new_link:
* @factory: the #NMDeviceFactory
* @link: the new link
* @error: error if the link could be claimed but an error occurred
*
* The NetworkManager core was notified of a new link which the plugin
* may want to claim and create a #NMDevice subclass for. If the link
* represents a device the factory is capable of claiming, but the device
* could not be created, %NULL should be returned and @error should be set.
* %NULL should always be returned and @error should never be set if the
* factory cannot create devices for the type which @link represents.
*
* Returns: the #NMDevice if the link was claimed and created, %NULL if not
*/
NMDevice * (*new_link) (NMDeviceFactory *factory,
NMPlatformLink *plink,
GError **error);
/* Signals */
/**
* device_added:
* @factory: the #NMDeviceFactory
* @device: the new #NMDevice subclass
*
* The factory emits this signal if it finds a new device by itself.
*/
void (*device_added) (NMDeviceFactory *factory, NMDevice *device);
/**
* component_added:
* @factory: the #NMDeviceFactory
* @component: a new component which existing devices may wish to claim
*
* The factory emits this signal when it finds a new component. For example,
* the WWAN factory may indicate that a new modem is available, which an
* existing Bluetooth device may wish to claim. If no device claims the
* component, the plugin is allowed to create a new #NMDevice instance for
* that component and emit the "device-added" signal.
*
* Returns: %TRUE if the component was claimed by a device, %FALSE if not
*/
gboolean (*component_added) (NMDeviceFactory *factory, GObject *component);
};
GType nm_device_factory_get_type (void);
NMDevice * nm_device_factory_new_link (NMDeviceFactory *factory,
NMPlatformLink *plink,
GError **error);
/* For use by implementations */
gboolean nm_device_factory_emit_component_added (NMDeviceFactory *factory,
GObject *component);
#endif /* NM_DEVICE_FACTORY_H */
|