nm-system-config-interface.h 5.97 KB
Newer Older
Dan Williams's avatar
Dan Williams committed
1 2
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
3 4 5 6 7 8 9 10 11 12 13
 *
 * 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.
 *
14 15 16
 * 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.
17
 *
18
 * Copyright (C) 2007 - 2011 Red Hat, Inc.
Dan Williams's avatar
Dan Williams committed
19
 * Copyright (C) 2008 Novell, Inc.
20 21 22 23 24 25 26 27
 */

#ifndef NM_SYSTEM_CONFIG_INTERFACE_H
#define NM_SYSTEM_CONFIG_INTERFACE_H

#include <glib.h>
#include <glib-object.h>
#include <nm-connection.h>
28
#include <nm-settings-connection.h>
29 30 31 32

G_BEGIN_DECLS

#define PLUGIN_PRINT(pname, fmt, args...) \
33
	{ g_message ("   " pname ": " fmt, ##args); }
34 35 36 37 38 39 40 41

#define PLUGIN_WARN(pname, fmt, args...) \
	{ g_warning ("   " pname ": " fmt, ##args); }


/* Plugin's factory function that returns a GObject that implements
 * NMSystemConfigInterface.
 */
42
GObject * nm_system_config_factory (void);
43 44 45 46 47 48 49 50 51

#define NM_TYPE_SYSTEM_CONFIG_INTERFACE      (nm_system_config_interface_get_type ())
#define NM_SYSTEM_CONFIG_INTERFACE(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE, NMSystemConfigInterface))
#define NM_IS_SYSTEM_CONFIG_INTERFACE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE))
#define NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE, NMSystemConfigInterface))


#define NM_SYSTEM_CONFIG_INTERFACE_NAME "name"
#define NM_SYSTEM_CONFIG_INTERFACE_INFO "info"
52
#define NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES "capabilities"
53
#define NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME "hostname"
54

55 56 57
#define NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED "unmanaged-specs-changed"
#define NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED "connection-added"

58 59 60
typedef enum {
	NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE = 0x00000000,
	NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS = 0x00000001,
61
	NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME = 0x00000002
62

63 64 65
	/* When adding more capabilities, be sure to update the "Capabilities"
	 * property max value in nm-system-config-interface.c.
	 */
66 67
} NMSystemConfigInterfaceCapabilities;

68 69 70 71 72
typedef enum {
	NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST = 0x1000,

	NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME = NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST,
	NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
73
	NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES,
74
	NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
75 76 77 78 79 80 81 82
} NMSystemConfigInterfaceProp;


typedef struct _NMSystemConfigInterface NMSystemConfigInterface;

struct _NMSystemConfigInterface {
	GTypeInterface g_iface;

83
	/* Called when the plugin is loaded to initialize it */
84
	void     (*init) (NMSystemConfigInterface *config);
85

86
	/* Returns a GSList of NMSettingsConnection objects that represent
87 88
	 * connections the plugin knows about.  The returned list is freed by the
	 * system settings service.
89
	 */
90 91
	GSList * (*get_connections) (NMSystemConfigInterface *config);

92
	/*
93 94 95 96 97 98 99 100 101 102
	 * Return a string list of specifications of devices which NetworkManager
	 * should not manage.  Returned list will be freed by the system settings
	 * service, and each element must be allocated using g_malloc() or its
	 * variants (g_strdup, g_strdup_printf, etc).
	 *
	 * Each string in the list must follow the format <method>:<data>, where
	 * the method and data are one of the following:
	 *
	 * Method: mac    Data: device MAC address formatted with leading zeros and
	 *                      lowercase letters, like 00:0a:0b:0c:0d:0e
103
	 *
Dan Williams's avatar
Dan Williams committed
104 105 106 107 108
	 * Method: s390-subchannels  Data: string of 2 or 3 s390 subchannels
	 *                                 separated by commas (,) that identify the
	 *                                 device, like "0.0.09a0,0.0.09a1,0.0.09a2".
	 *                                 The string may contain only the following
	 *                                 characters: [a-fA-F0-9,.]
109
	 */
110
	GSList * (*get_unmanaged_specs) (NMSystemConfigInterface *config);
111

112
	/*
113
	 * Initialize the plugin-specific connection and return a new
114
	 * NMSettingsConnection subclass that contains the same settings as the
115 116
	 * original connection.  The connection should only be saved to backing
	 * storage if @save_to_disk is TRUE.
117
	 */
118 119
	NMSettingsConnection * (*add_connection) (NMSystemConfigInterface *config,
	                                          NMConnection *connection,
120
	                                          gboolean save_to_disk,
121
	                                          GError **error);
122

123
	/* Signals */
124 125

	/* Emitted when a new connection has been found by the plugin */
126
	void (*connection_added)   (NMSystemConfigInterface *config,
127
	                            NMSettingsConnection *connection);
128

129 130
	/* Emitted when the list of unmanaged device specifications changes */
	void (*unmanaged_specs_changed) (NMSystemConfigInterface *config);
131 132 133 134
};

GType nm_system_config_interface_get_type (void);

135
void nm_system_config_interface_init (NMSystemConfigInterface *config,
136
                                      gpointer unused);
137

138
GSList *nm_system_config_interface_get_connections (NMSystemConfigInterface *config);
139

140
GSList *nm_system_config_interface_get_unmanaged_specs (NMSystemConfigInterface *config);
141

142 143
NMSettingsConnection *nm_system_config_interface_add_connection (NMSystemConfigInterface *config,
                                                                 NMConnection *connection,
144
                                                                 gboolean save_to_disk,
145
                                                                 GError **error);
146

147 148 149
G_END_DECLS

#endif	/* NM_SYSTEM_CONFIG_INTERFACE_H */