1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details:
13 * Copyright (C) 2012 Red Hat, Inc.
16 #include "nm-default.h"
18 #include "nm-connection-provider.h"
21 G_DEFINE_INTERFACE (NMConnectionProvider, nm_connection_provider, G_TYPE_OBJECT)
24 nm_connection_provider_get_best_connections (NMConnectionProvider *self,
28 NMConnectionFilterFunc func,
31 g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), NULL);
33 if (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->get_best_connections)
34 return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->get_best_connections (self, max_requested, ctype1, ctype2, func, func_data);
39 nm_connection_provider_get_connections (NMConnectionProvider *self)
41 g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), NULL);
43 if (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->get_connections)
44 return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->get_connections (self);
49 * nm_connection_provider_add_connection:
50 * @self: the #NMConnectionProvider
51 * @connection: the source connection to create a new #NMSettingsConnection from
52 * @save_to_disk: %TRUE to save the connection to disk immediately, %FALSE to
54 * @error: on return, a location to store any errors that may occur
56 * Creates a new #NMSettingsConnection for the given source @connection.
57 * The plugin owns the returned object and the caller must reference the object
58 * to continue using it.
60 * Returns: the new #NMSettingsConnection or %NULL
63 nm_connection_provider_add_connection (NMConnectionProvider *self,
64 NMConnection *connection,
65 gboolean save_to_disk,
68 g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), NULL);
70 g_assert (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->add_connection);
71 return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->add_connection (self, connection, save_to_disk, error);
75 * nm_connection_provider_get_connection_by_uuid:
76 * @self: the #NMConnectionProvider
77 * @uuid: the UUID to search for
79 * Returns: the connection with the given @uuid, or %NULL
82 nm_connection_provider_get_connection_by_uuid (NMConnectionProvider *self,
85 g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), NULL);
86 g_return_val_if_fail (uuid != NULL, NULL);
87 g_return_val_if_fail (nm_utils_is_uuid (uuid), NULL);
89 g_assert (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->get_connection_by_uuid);
90 return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->get_connection_by_uuid (self, uuid);
93 /*****************************************************************************/
96 nm_connection_provider_default_init (NMConnectionProviderInterface *g_iface)
98 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
99 static gboolean initialized = FALSE;
106 g_signal_new (NM_CP_SIGNAL_CONNECTION_ADDED,
109 G_STRUCT_OFFSET (NMConnectionProviderInterface, connection_added),
111 g_cclosure_marshal_VOID__OBJECT,
112 G_TYPE_NONE, 1, G_TYPE_OBJECT);
114 g_signal_new (NM_CP_SIGNAL_CONNECTION_UPDATED,
117 G_STRUCT_OFFSET (NMConnectionProviderInterface, connection_updated),
119 g_cclosure_marshal_VOID__OBJECT,
120 G_TYPE_NONE, 1, G_TYPE_OBJECT);
122 g_signal_new (NM_CP_SIGNAL_CONNECTION_REMOVED,
125 G_STRUCT_OFFSET (NMConnectionProviderInterface, connection_removed),
127 g_cclosure_marshal_VOID__OBJECT,
128 G_TYPE_NONE, 1, G_TYPE_OBJECT);