/*
 * ReadOpts.java
 *
 * Copyright (c) 2007  Vreixo Formoso
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * See COPYING file for details.
 */

package org.pykix.libburnia.libburn;

import org.pykix.libburnia.bindings.Proxy;

/**
 * 
 * @author Vreixo Formoso
 * @since 0.1
 */
public class ReadOpts extends Proxy {

	ReadOpts(long ptr) {
		super(ptr);
	}
	
	/**
	 * Sets whether to read in raw mode or not.
	 * 
	 * @param rawMode
	 * 		If <code>true</code>, reading will be done in raw mode, so that 
	 * 		everything in the data tracks on the disc is read, including 
	 * 		headers.
	 */
	public void setRaw(boolean rawMode) {
		burn_read_opts_set_raw(pointerOf(this), rawMode);
	}
	
	/**
	 * Sets whether to report c2 errors or not.
	 * 
	 * @param c2errors
	 * 		If <code>true</code>, report c2 errors.
	 */
	public void setC2errors(boolean c2errors) {
		burn_read_opts_set_c2errors(pointerOf(this), c2errors);
	}
	
	/**
	 * Sets whether to read subcodes from audio tracks or not.
	 * 
	 * @param subcodesAudio
	 * 		If <code>true</code>, read subcodes from audio tracks on the disc.
	 */
	public void readSubcodesAudio(boolean subcodesAudio) {
		burn_read_opts_read_subcodes_audio(pointerOf(this), subcodesAudio);
	}
	
	/**
	 * Sets whether to read subcodes from data tracks or not.
	 * 
	 * @param subcodesData
	 * 		If <code>true</code>, read subcodes from data tracks on the disc.
	 */
	public void readSubcodesData(boolean subcodesData) {
		burn_read_opts_read_subcodes_data(pointerOf(this), subcodesData);
	}
	
	/**
	 * Sets whether to recover errors if possible.
	 * 
	 * @param her
	 * 		If <code>true</code>, attempt to recover errors if possible.
	 */
	public void setHardwareErrorRecovery(boolean her) {
		burn_read_opts_set_hardware_error_recovery(pointerOf(this), her);
	}
	
	/**
	 * Sets whether to report recovered errors or not.
	 * 
	 * @param rre
	 * 		If <code>true</code>, recovered errors will be reported.
	 */
	public void reportRecoveredErrors(boolean rre) {
		burn_read_opts_report_recovered_errors(pointerOf(this), rre);
	}
	
	/**
	 * Sets whether blocks with unrecoverable errors should be read or not.
	 * 
	 * @param tdb
	 * 		If <code>true</code>, blocks with unrecoverable errors will still 
	 * 		be read.
	 */
	public void transferDamagedBlocks(boolean tdb) {
		burn_read_opts_transfer_damaged_blocks(pointerOf(this), tdb);
	}
	
	/**
	 * Sets the number of retries to attempt when trying to correct an error.
	 * 
	 * @param r
	 * 		The number of retries to attempt when correcting an error.
	 */
	public void setHardwareErrorRetries(int r) {
		burn_read_opts_set_hardware_error_retries(pointerOf(this), r);
	}
	
	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		burn_read_opts_free( pointerOf(this) );
	}

	private static native void burn_read_opts_free(long opts);

	private static native void burn_read_opts_set_raw(long opts, boolean raw);
	
	private static native void burn_read_opts_set_c2errors(long opts, 
			boolean c2errors);
	
	private static native void burn_read_opts_read_subcodes_audio(long opts,
			boolean subcodesAudio);

	private static native void burn_read_opts_read_subcodes_data(long opts,
			boolean subcodesData);

	private static native void burn_read_opts_set_hardware_error_recovery(
			long opts, boolean hardware_error_recovery);
	
	private static native void burn_read_opts_report_recovered_errors(
			long opts, boolean report_recovered_errors);
	
	private static native void burn_read_opts_transfer_damaged_blocks(
			long opts, boolean transfer_damaged_blocks);
	
	private static native void burn_read_opts_set_hardware_error_retries(
			long opts, int hardware_error_retries);
}
