/* util.c generated by valac 0.56.19, the Vala compiler
 * generated from util.vala, do not modify */

#include <nice.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include "ice.h"

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_free0(var) (var = (g_free (var), NULL))

VALA_EXTERN gboolean dino_plugins_ice_is_component_ready (NiceAgent* agent,
                                              guint stream_id,
                                              guint component_id);
VALA_EXTERN GeeList* dino_plugins_ice_get_local_ip_addresses (void);
static void _g_free0_ (gpointer var);
static inline void _g_list_free__g_free0_ (GList* self);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

gboolean
dino_plugins_ice_is_component_ready (NiceAgent* agent,
                                     guint stream_id,
                                     guint component_id)
{
	NiceComponentState state = 0;
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (agent != NULL, FALSE);
	state = nice_agent_get_component_state (agent, stream_id, component_id);
	if (state == NICE_COMPONENT_STATE_CONNECTED) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = state == NICE_COMPONENT_STATE_READY;
	}
	result = _tmp0_;
	return result;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static inline void
_g_list_free__g_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_free0_);
}

GeeList*
dino_plugins_ice_get_local_ip_addresses (void)
{
	GeeList* _result_ = NULL;
	GeeArrayList* _tmp0_;
	GList* _tmp1_;
	GeeList* result;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_result_ = (GeeList*) _tmp0_;
	_tmp1_ = nice_interfaces_get_local_ips (FALSE);
	{
		GList* ip_address_collection = NULL;
		GList* ip_address_it = NULL;
		ip_address_collection = _tmp1_;
		for (ip_address_it = ip_address_collection; ip_address_it != NULL; ip_address_it = ip_address_it->next) {
			gchar* _tmp2_;
			gchar* ip_address = NULL;
			_tmp2_ = g_strdup ((const gchar*) ip_address_it->data);
			ip_address = _tmp2_;
			{
				GeeList* _tmp3_;
				const gchar* _tmp4_;
				_tmp3_ = _result_;
				_tmp4_ = ip_address;
				gee_collection_add ((GeeCollection*) _tmp3_, _tmp4_);
				_g_free0 (ip_address);
			}
		}
		(ip_address_collection == NULL) ? NULL : (ip_address_collection = (_g_list_free__g_free0_ (ip_address_collection), NULL));
	}
	result = _result_;
	return result;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

