예제 #1
0
static ArvDevice *
arv_gv_interface_open_device (ArvInterface *interface, const char *device_id)
{
	ArvGvInterface *gv_interface;
	ArvDevice *device = NULL;
	ArvGvInterfaceDeviceInfos *device_infos;
	GInetAddress *device_address;

	gv_interface = ARV_GV_INTERFACE (interface);

	if (device_id == NULL) {
		GList *device_list;

		device_list = g_hash_table_get_values (gv_interface->priv->devices);
		device_infos = device_list != NULL ? device_list->data : NULL;
		g_list_free (device_list);
	} else {
		device_infos = g_hash_table_lookup (gv_interface->priv->devices, device_id);

		if (device_infos == NULL)
			device_infos = g_hash_table_lookup (gv_interface->priv->devices_by_mac, device_id);
	}

	if (device_infos == NULL)
		return NULL;

	device_address = g_inet_address_new_from_bytes
		(&device_infos->discovery_data[ARV_GVBS_CURRENT_IP_ADDRESS_OFFSET],
		 G_SOCKET_FAMILY_IPV4);
	device = arv_gv_device_new (device_infos->interface_address, device_address);
	g_object_unref (device_address);

	return device;
}
예제 #2
0
static void
arv_gv_interface_update_device_list (ArvInterface *interface, GArray *device_ids)
{
	ArvGvInterface *gv_interface;
	GHashTableIter iter;
	gpointer key, value;

	gv_interface = ARV_GV_INTERFACE (interface);

	arv_gv_interface_send_discover_packet (gv_interface);
	arv_gv_interface_receive_hello_packet (gv_interface);

	g_array_set_size (device_ids, 0);

	g_hash_table_iter_init (&iter, gv_interface->priv->devices);
	while (g_hash_table_iter_next (&iter, &key, &value)) {
		ArvInterfaceDeviceIds *ids;
		ArvGvInterfaceDeviceInfos *infos = value;

		ids = g_new0 (ArvInterfaceDeviceIds, 1);

		ids->device = g_strdup (key);
                ids->physical = g_strdup (infos->mac_string);

		g_array_append_val (device_ids, ids);
	}
}
예제 #3
0
static ArvDevice *
arv_gv_interface_open_device (ArvInterface *interface, const char *device_id)
{
	ArvGvInterface *gv_interface;
	ArvDevice *device = NULL;
	ArvGvInterfaceDeviceInfos *device_infos;
	GInetAddress *device_address;

	gv_interface = ARV_GV_INTERFACE (interface);

	if (device_id == NULL) {
		GList *device_list;

		device_list = g_hash_table_get_values (gv_interface->priv->devices);
		device_infos = device_list != NULL ? device_list->data : NULL;
		g_list_free (device_list);
	} else
		device_infos = g_hash_table_lookup (gv_interface->priv->devices, device_id);

	if (device_infos == NULL)
		return NULL;

	device_address = _device_infos_to_ginetaddress (device_infos);
	device = arv_gv_device_new (device_infos->interface_address, device_address);
	g_object_unref (device_address);

	return device;
}
예제 #4
0
static void
arv_gv_interface_update_device_list (ArvInterface *interface, GArray *device_ids)
{
	ArvGvInterface *gv_interface;
	GHashTableIter iter;
	gpointer key, value;

	gv_interface = ARV_GV_INTERFACE (interface);

	arv_gv_interface_discover (gv_interface);

	g_array_set_size (device_ids, 0);

	g_hash_table_iter_init (&iter, gv_interface->priv->devices);
	while (g_hash_table_iter_next (&iter, &key, &value)) {
		ArvGvInterfaceDeviceInfos *infos = value;

		if (g_strcmp0 (key, infos->name) == 0) {
			ArvInterfaceDeviceIds *ids;
			GInetAddress *device_address;

			ids = g_new0 (ArvInterfaceDeviceIds, 1);

			ids->device = g_strdup (key);
			ids->physical = g_strdup (infos->mac_string);
			device_address = _device_infos_to_ginetaddress (infos);
			ids->address = g_inet_address_to_string (device_address);
			g_object_unref (device_address);

			g_array_append_val (device_ids, ids);
		}
	}
}
예제 #5
0
static void
arv_gv_interface_finalize (GObject *object)
{
	ArvGvInterface *gv_interface = ARV_GV_INTERFACE (object);

	g_hash_table_unref (gv_interface->priv->devices);
	gv_interface->priv->devices = NULL;

	parent_class->finalize (object);
}
예제 #6
0
static void
arv_gv_interface_finalize (GObject *object)
{
	ArvGvInterface *gv_interface = ARV_GV_INTERFACE (object);

	g_hash_table_unref (gv_interface->priv->devices_by_mac);
	g_hash_table_unref (gv_interface->priv->devices);
	gv_interface->priv->devices_by_mac = NULL;
	gv_interface->priv->devices = NULL;

	arv_gv_interface_free_discover_infos_list (gv_interface);

	parent_class->finalize (object);
}