Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions java/sage/DVBCaptureDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package sage;

import jtux.*;

/**
*
* @author Jean-Francois based on IVTV by Narflex
Expand Down
2 changes: 0 additions & 2 deletions java/sage/FirewireCaptureDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package sage;

import jtux.*;

/**
*
* @author Jean-Francois based on IVTV by Narflex
Expand Down
184 changes: 0 additions & 184 deletions java/sage/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1057,190 +1057,6 @@ public static boolean isLocalhostAddress(java.net.InetAddress inetAddress)
return false;
}

static int _IOC_NRBITS = 8;
static int _IOC_TYPEBITS = 8;
static int _IOC_SIZEBITS = 14;
static int _IOC_DIRBITS = 2;

static int _IOC_NRMASK = ((1 << _IOC_NRBITS)-1);
static int _IOC_TYPEMASK = ((1 << _IOC_TYPEBITS)-1);
static int _IOC_SIZEMASK = ((1 << _IOC_SIZEBITS)-1);
static int _IOC_DIRMASK = ((1 << _IOC_DIRBITS)-1);

static int _IOC_NRSHIFT = 0;
static int _IOC_TYPESHIFT = (_IOC_NRSHIFT+_IOC_NRBITS);
static int _IOC_SIZESHIFT = (_IOC_TYPESHIFT+_IOC_TYPEBITS);
static int _IOC_DIRSHIFT = (_IOC_SIZESHIFT+_IOC_SIZEBITS);

static int _IOC_NONE = 0;
static int _IOC_WRITE = 1;
static int _IOC_READ = 2;

static int _IOW(int type, int nr, int size)
{
int dir=_IOC_WRITE;
return (((dir) << _IOC_DIRSHIFT) |
((type) << _IOC_TYPESHIFT) |
((nr) << _IOC_NRSHIFT) |
((size) << _IOC_SIZESHIFT));
}

static int IOCTL_USB_CONNECTINFO = _IOW('U', 17, 8 /* struct usb_connectinfo */);

static long getUSBHWID()
{
// First get what is supposed to be the serial number; and then verify it exists
String targetSerial = exec(new String[] { "tbutil", "getserial" });

// Now convert this to the 64-bit long for the targetSerialID
long targetSerialID = 0;
int targetBitOffset = 0;
try
{
int idx = 0;
long currRead = targetSerial.charAt(idx++);
while (true)
{
currRead = Integer.parseInt(((char) currRead) + "", 16);
targetSerialID = targetSerialID ^ ((currRead & 0xF) << targetBitOffset);
if (idx >= targetSerial.length())
break;
currRead = targetSerial.charAt(idx++);
targetBitOffset += 4;
targetBitOffset = targetBitOffset % 64;
}
}
catch (Exception nfe)
{
}


// Check in /sys/bus/usb/devices to find anything in there that has a 'serial' field; but only check the ones
// that start with a number.
String[] usbdevids = new java.io.File("/sys/bus/usb/devices").list();
for (int i = 0; usbdevids != null && i < usbdevids.length; i++)
{
//System.out.println("Checking USB Dev ID=" + usbdevids[i]);
if (Character.isDigit(usbdevids[i].charAt(0)))
{
// Check for the 'serial' field
java.io.File serialFile = new java.io.File("/sys/bus/usb/devices/" + usbdevids[i] + "/serial");
if (serialFile.isFile())
{
//System.out.println("Serial exists for this device...");
int usbMajor = Integer.parseInt(usbdevids[i].substring(0, 1));
java.io.Reader inReader = null;
int usbMinor = -1;
try
{
inReader = new java.io.FileReader("/sys/bus/usb/devices/" + usbdevids[i] + "/devnum");
usbMinor = Integer.parseInt(((char)inReader.read()) + "");
inReader.close();
inReader = null;
}
catch (Exception e)
{
continue;
}
java.text.DecimalFormat leadZeros = new java.text.DecimalFormat("000");
//System.out.println("USB dev num " + usbMajor + "-" + usbMinor);
String verificationDevice = "/dev/bus/usb/" + leadZeros.format(usbMajor) + "/" + leadZeros.format(usbMinor);
//System.out.println("Verifying w/ device:" + verificationDevice);
int usb_fd = -1;
byte[] buf1 = new byte[8];
byte[] desc = new byte[18];
try
{
usb_fd = jtux.UFile.open(verificationDevice, jtux.UConstant.O_RDWR);
//System.out.println("ioctl "+IOCTL_USB_CONNECTINFO);
int retval = jtux.UFile.ioctl(usb_fd, IOCTL_USB_CONNECTINFO, buf1);
if(retval<0)
{
//System.out.println("Error "+retval);
continue;
}
else
{
//these bufs create the 'devnum', but you'll need to check endian in java.nio.Buffer
int checkedDevNum = 0;
if(java.nio.ByteOrder.nativeOrder() != java.nio.ByteOrder.BIG_ENDIAN)
checkedDevNum = ((buf1[3] & 0xFF) << 24) | ((buf1[2] & 0xFF) << 16) | ((buf1[1] & 0xFF) << 8) | (buf1[0] & 0xFF);
else
checkedDevNum = ((buf1[0] & 0xFF) << 24) | ((buf1[1] & 0xFF) << 16) | ((buf1[2] & 0xFF) << 8) | (buf1[3] & 0xFF);
//System.out.println("checked dev num=" + checkedDevNum);
if (checkedDevNum != usbMinor)
continue;
}
jtux.UFile.read(usb_fd, desc, 18);
// also make sure the serial index is non-zero
//System.out.println("Manuf index "+ (desc[14]&0xFF) +
// " Product index "+ (desc[15]&0xFF) +
// " Serial index "+ (desc[16]&0xFF));
if ((desc[16] & 0xFF) == 0)
continue;
}
catch (jtux.UErrorException e)
{
//System.out.println(e);
continue;
}
finally
{
try
{
jtux.UFile.close(usb_fd);
}
catch (jtux.UErrorException e1)
{
}
usb_fd=-1;
}

// Now read the serial and convert it to a 64-bit integer to return
long rv = 0;
int rvBitOffset = 0;
try
{
inReader = new java.io.FileReader("/sys/bus/usb/devices/" + usbdevids[i] + "/serial");
long currRead = inReader.read();
while (currRead != -1)
{
currRead = Integer.parseInt(((char) currRead) + "", 16);
rv = rv ^ ((currRead & 0xF) << rvBitOffset);
//System.out.println("Updating HWID rv=" + rv + " currRead=" + currRead + " rvBitOffset=" + rvBitOffset);
currRead = inReader.read();
rvBitOffset += 4;
rvBitOffset = rvBitOffset % 64;
}
inReader.close();
inReader = null;
}
catch (NumberFormatException nfe)
{
// This can happen reading the line terminator
if (inReader != null)
{
try
{
inReader.close();
inReader = null;
}
catch (Exception e2){}
}
}
catch (Exception e)
{
continue;
}
if (targetSerialID != 0 && Math.abs(targetSerialID) != Math.abs(rv))
continue;
return Math.abs(rv);
}
}
}
return 0;
}

public static final int SMB_MOUNT_EXISTS = 0;
public static final int SMB_MOUNT_SUCCEEDED = 1;
public static final int SMB_MOUNT_FAILED = -1;
Expand Down