/* * Progress.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; /** * Operation progress report. All values are 0 based indices. * * @author Vreixo Formoso * @since 0.1 */ /* * I've implemented this as a proxy, because I think is a good option given * the normal usage of this object. The 3 considered options are: * - One option is implement this as a pure Java option, created in JNI * with a copy of the C struct and returned back to Java. This involves * creation of a object each time the progress is retrieved, so it's not * a good option. * - Implement this as a proxy. C code can pass directly the proxied C struct * so is a fast operation. The problem is that consult of Progress values * involves a JNI call. * - Another option, maybe better, is treat this as a Java option whose fields * are updated from JNI code. * For now, the proxy options seems a good enought approach. */ public class Progress extends Proxy { /** * Create a new Progress object. * *
* This can be used with {@link Drive#getDriveStatus(Progress)} to
* get the progress of a burn operation.
*/
public Progress() {
super( burn_progress_new() );
}
/** Get the total number of sessions. */
public int getSessions() {
return burn_progress_sessions( pointerOf(this) );
}
/** Get current session. */
public int getSession() {
return burn_progress_session( pointerOf(this) );
}
/** Get the total number of tracks. */
public int getTracks() {
return burn_progress_tracks( pointerOf(this) );
}
/** Get current track. */
public int getTrack() {
return burn_progress_track( pointerOf(this) );
}
/** Get the total number of indices. */
public int getIndices() {
return burn_progress_indices( pointerOf(this) );
}
/** Get current index. */
public int getIndex() {
return burn_progress_index( pointerOf(this) );
}
/** Get the starting logical block address. */
public int getStartSector() {
return burn_progress_start_sector( pointerOf(this) );
}
/**
* On write: The number of sectors.
* On blank: 0x10000 as upper limit for relative progress steps.
*/
public int getSectors() {
return burn_progress_sectors( pointerOf(this) );
}
/**
* On write: The current sector being processed.
* On blank: Relative progress steps 0 to 0x10000.
*/
public int getSector() {
return burn_progress_sector( pointerOf(this) );
}
/**
* Get the capacity of the drive buffer.
*/
public int getBufferCapacity() {
return burn_progress_buffer_capacity( pointerOf(this) );
}
/**
* Get the free space in the drive buffer (might be slightly outdated).
*/
public int getBufferAvailable() {
return burn_progress_buffer_available( pointerOf(this) );
}
/** Get the number of bytes sent to the drive buffer. */
public long getBufferedBytes() {
return burn_progress_buffered_bytes( pointerOf(this) );
}
/**
* The minimum number of buffered bytes. (Caution: Before surely
* one buffer size of bytes was processed, this value is -1
.)
*/
public int getBufferMinFill() {
return burn_progress_buffer_min_fill( pointerOf(this) );
}
@Override
protected void finalize() throws Throwable {
super.finalize();
burn_progress_free( pointerOf(this) );
}
private static native long burn_progress_new();
private static native void burn_progress_free(long p);
private static native int burn_progress_sessions(long p);
private static native int burn_progress_session(long p);
private static native int burn_progress_tracks(long p);
private static native int burn_progress_track(long p);
private static native int burn_progress_indices(long p);
private static native int burn_progress_index(long p);
private static native int burn_progress_start_sector(long p);
private static native int burn_progress_sectors(long p);
private static native int burn_progress_sector(long p);
private static native int burn_progress_buffer_capacity(long p);
private static native int burn_progress_buffer_available(long p);
private static native long burn_progress_buffered_bytes(long p);
private static native int burn_progress_buffer_min_fill(long p);
}