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 #ifndef __NETWORKMANAGER_CONNECTION_PROVIDER_H__
17 #define __NETWORKMANAGER_CONNECTION_PROVIDER_H__
19 #include <nm-connection.h>
21 #include "nm-default.h"
23 #define NM_TYPE_CONNECTION_PROVIDER (nm_connection_provider_get_type ())
24 #define NM_CONNECTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProvider))
25 #define NM_IS_CONNECTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_PROVIDER))
26 #define NM_CONNECTION_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProviderInterface))
28 #define NM_CP_SIGNAL_CONNECTION_ADDED "cp-connection-added"
29 #define NM_CP_SIGNAL_CONNECTION_UPDATED "cp-connection-updated"
30 #define NM_CP_SIGNAL_CONNECTION_REMOVED "cp-connection-removed"
34 * NMConnectionFilterFunc:
35 * @provider: The provider requesting the filtering
36 * @connection: the connection to be filtered
37 * @func_data: the caller-provided data pointer
39 * Returns: %TRUE to allow the connection, %FALSE to ignore it
41 typedef gboolean (*NMConnectionFilterFunc) (NMConnectionProvider *provider,
42 NMConnection *connection,
47 GTypeInterface g_iface;
50 GSList * (*get_best_connections) (NMConnectionProvider *self,
54 NMConnectionFilterFunc func,
57 const GSList * (*get_connections) (NMConnectionProvider *self);
59 NMConnection * (*add_connection) (NMConnectionProvider *self,
60 NMConnection *connection,
61 gboolean save_to_disk,
64 NMConnection * (*get_connection_by_uuid) (NMConnectionProvider *self,
68 void (*connection_added) (NMConnectionProvider *self, NMConnection *connection);
70 void (*connection_updated) (NMConnectionProvider *self, NMConnection *connection);
72 void (*connection_removed) (NMConnectionProvider *self, NMConnection *connection);
74 } NMConnectionProviderInterface;
76 GType nm_connection_provider_get_type (void);
79 * nm_connection_provider_get:
81 * Returns: the global #NMConnectionProvider
83 NMConnectionProvider *nm_connection_provider_get (void);
86 * nm_connection_provider_get_best_connections:
87 * @self: the #NMConnectionProvider
88 * @max_requested: if non-zero, the maximum number of connections to return
89 * @ctype1: an #NMSetting base type (eg NM_SETTING_WIRELESS_SETTING_NAME) to
90 * filter connections against
91 * @ctype2: a second #NMSetting base type (eg NM_SETTING_WIRELESS_SETTING_NAME)
92 * to filter connections against
93 * @func: caller-supplied function for filtering connections
94 * @func_data: caller-supplied data passed to @func
96 * Returns: a #GSList of #NMConnection objects in sorted order representing the
97 * "best" or highest-priority connections filtered by @ctype1 and/or @ctype2,
98 * and/or @func. Caller is responsible for freeing the returned #GSList, but
99 * the contained values do not need to be unreffed.
101 GSList *nm_connection_provider_get_best_connections (NMConnectionProvider *self,
105 NMConnectionFilterFunc func,
109 * nm_connection_provider_get_connections:
110 * @self: the #NMConnectionProvider
112 * Returns: a #GSList of #NMConnection objects representing all known
113 * connections. Returned list is owned by the connection provider and must
116 const GSList *nm_connection_provider_get_connections (NMConnectionProvider *self);
119 * nm_connection_provider_add_connection:
120 * @self: the #NMConnectionProvider
121 * @connection: the connection to be added
122 * @save_to_disk: whether to store the connection on disk
123 * @error: returns any error if adding fails
125 * returns: a newly added #NMConnection.
127 NMConnection *nm_connection_provider_add_connection (NMConnectionProvider *self,
128 NMConnection *connection,
129 gboolean save_to_disk,
132 NMConnection *nm_connection_provider_get_connection_by_uuid (NMConnectionProvider *self,
135 #endif /* __NETWORKMANAGER_CONNECTION_PROVIDER_H__ */