コード例 #1
0
ファイル: applet-dialogs.c プロジェクト: mirsal/nm-applet
static NMConnection *
get_connection_for_active (NMApplet *applet, NMActiveConnection *active)
{
	GSList *list, *iter;
	NMConnection *connection = NULL;
	NMConnectionScope scope;
	const char *path;

	scope = nm_active_connection_get_scope (active);
	g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);

	path = nm_active_connection_get_connection (active);
	g_return_val_if_fail (path != NULL, NULL);

	list = applet_get_all_connections (applet);
	for (iter = list; iter; iter = g_slist_next (iter)) {
		NMConnection *candidate = NM_CONNECTION (iter->data);

		if (   (nm_connection_get_scope (candidate) == scope)
			   && !strcmp (nm_connection_get_path (candidate), path)) {
			connection = candidate;
			break;
		}
	}

	g_slist_free (list);

	return connection;
}
コード例 #2
0
static NMConnection *
get_connection_for_active (NMActiveConnection *active)
{
	NMConnectionScope scope;
	const char *path;

	g_return_val_if_fail (active != NULL, NULL);

	path = nm_active_connection_get_connection (active);
	g_return_val_if_fail (path != NULL, NULL);

	scope = nm_active_connection_get_scope (active);
	if (scope == NM_CONNECTION_SCOPE_USER)
		return (NMConnection *) g_hash_table_lookup (user_connections, path);
	else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
		return (NMConnection *) g_hash_table_lookup (system_connections, path);

	g_warning ("error: unknown connection scope");
	return NULL;
}