// Path: source/java/src/jmtp/PortableDevice.java
// public interface PortableDevice {
//     
//     public String getFriendlyName();
//     public String getManufacturer();
//     public String getDescription();
//     public void open(String appName, int appMajor, int appMinor, int appRevision);
//     public void open();
//     public void close();
//     public PortableDeviceObject[] getRootObjects();
//     public PortableDeviceObject[] getPortableDeviceObjectsFromPersistentUniqueIDs(String[] persistentUniqueIDs);
//     public PortableDeviceObject getPortableDeviceObjectsFromPersistentUniqueIDs(String persistentUniqueID);
//     public String getSerialNumber();
//     public String getFirmwareVersion();
//     public String getModel();
//     public String getProtocol();
//     public String getSyncPartner();
//     public int getPowerLevel();
//     public PortableDeviceType getType();
//     public PowerSource getPowerSource();
//     public boolean isNonConsumableSupported();
// }
// 
// Path: source/java/src/jmtp/PortableDeviceFolderObject.java
// public interface PortableDeviceFolderObject extends PortableDeviceObject {
//     
//     public PortableDeviceObject[] getChildObjects();
//     public PortableDeviceAudioObject addAudioObject(File bestand, 
//     		String artist, String title, BigInteger duration) throws FileNotFoundException, IOException;
//     public PortableDeviceAudioObject addAudioObject(File file,
// 			String artist, String title, BigInteger duration, 
// 			String genre, String album, Date releaseDate, int track) throws FileNotFoundException, IOException;
//     public PortableDevicePlaylistObject createPlaylistObject(String name,
//     		PortableDeviceObject[] references);
//     public PortableDeviceFolderObject createFolderObject(String name);
//     public void delete(boolean recursive);
// }
// 
// Path: source/java/src/jmtp/PortableDeviceManager.java
// public class PortableDeviceManager implements Iterable<PortableDevice> {
//     
//     private PortableDeviceManagerProxy proxy;
//     
//     public PortableDeviceManager() {
//         if(System.getProperty("os.name").toLowerCase().contains("windows")) {
//             proxy = new PortableDeviceManagerImplWin32();
//         }
//         else
//             throw new RuntimeException("not supported os");
//     }
//     
//     public void refreshDeviceList() {
//         proxy.refreshDeviceList();
//     }
//     
//     public PortableDevice[] getDevices() {
//         return proxy.getDevices();
//     }
// 
//     public Iterator<PortableDevice> iterator() {
//         return proxy.iterator();
//     }
// }
// 
// Path: source/java/src/jmtp/PortableDeviceObject.java
// public interface PortableDeviceObject {
//     
// 	public String getID();
// 	public String getName();
//     public String getOriginalFileName();
//     public boolean canDelete();
//     public boolean isHidden();
//     public boolean isSystemObject();
//     public boolean isDrmProtected();
//     public Date getDateModified();
//     public Date getDateCreated();
//     public Date getDateAuthored();
//     public PortableDeviceObject getParent();
//     public BigInteger getSize();
//     public String getPersistentUniqueIdentifier();
//     public String getSyncID();
//     public Guid getFormat();
//     
//     public void setSyncID(String value);	//TODO nog een exception kunnen gooien
//     
//     public void delete();
// }


import java.util.ArrayList;
import de.aok.no.kopra.agnes.desktop.util.LogUtil;
import jmtp.PortableDevice;
import jmtp.PortableDeviceFolderObject;
import jmtp.PortableDeviceManager;
import jmtp.PortableDeviceObject;
import jmtp.PortableDeviceStorageObject;

	private static PortableDeviceFolderObject getChildByName(PortableDeviceFolderObject folder, String z) {
		for (PortableDeviceObject object : folder.getChildObjects()) {
			if (object.getOriginalFileName().equals(z)) {
				LogUtil.debugPrint(LogUtil.LOG_LEVEL_FULL,MTPUtil.class.getSimpleName(),  "Found directory " + z);
				return (PortableDeviceFolderObject) object;
			}
		}
		return null;
	}

	private static PortableDeviceObject getChildByName(PortableDeviceStorageObject storage, String z) {
		for (PortableDeviceObject object : storage.getChildObjects()) {
			if (object.getOriginalFileName().equals(z)) {
				LogUtil.debugPrint(LogUtil.LOG_LEVEL_FULL, MTPUtil.class.getSimpleName(),  "Found directory " + z);
				return object;
			}
		}
		return null;
	}

	public static PortableDevice[] getDevices() {
		PortableDeviceManager manager = new PortableDeviceManager();
		manager.refreshDeviceList();
		return manager.getDevices();
	}

	public static void printDevices() {
		PortableDeviceManager manager = new PortableDeviceManager();

// Path: source/java/src/jmtp/PortableDevice.java
// public interface PortableDevice {
//     
//     public String getFriendlyName();
//     public String getManufacturer();
//     public String getDescription();
//     public void open(String appName, int appMajor, int appMinor, int appRevision);
//     public void open();
//     public void close();
//     public PortableDeviceObject[] getRootObjects();
//     public PortableDeviceObject[] getPortableDeviceObjectsFromPersistentUniqueIDs(String[] persistentUniqueIDs);
//     public PortableDeviceObject getPortableDeviceObjectsFromPersistentUniqueIDs(String persistentUniqueID);
//     public String getSerialNumber();
//     public String getFirmwareVersion();
//     public String getModel();
//     public String getProtocol();
//     public String getSyncPartner();
//     public int getPowerLevel();
//     public PortableDeviceType getType();
//     public PowerSource getPowerSource();
//     public boolean isNonConsumableSupported();
// }
// 
// Path: source/java/src/jmtp/PortableDeviceFolderObject.java
// public interface PortableDeviceFolderObject extends PortableDeviceObject {
//     
//     public PortableDeviceObject[] getChildObjects();
//     public PortableDeviceAudioObject addAudioObject(File bestand, 
//     		String artist, String title, BigInteger duration) throws FileNotFoundException, IOException;
//     public PortableDeviceAudioObject addAudioObject(File file,
// 			String artist, String title, BigInteger duration, 
// 			String genre, String album, Date releaseDate, int track) throws FileNotFoundException, IOException;
//     public PortableDevicePlaylistObject createPlaylistObject(String name,
//     		PortableDeviceObject[] references);
//     public PortableDeviceFolderObject createFolderObject(String name);
//     public void delete(boolean recursive);
// }
// 
// Path: source/java/src/jmtp/PortableDeviceManager.java
// public class PortableDeviceManager implements Iterable<PortableDevice> {
//     
//     private PortableDeviceManagerProxy proxy;
//     
//     public PortableDeviceManager() {
//         if(System.getProperty("os.name").toLowerCase().contains("windows")) {
//             proxy = new PortableDeviceManagerImplWin32();
//         }
//         else
//             throw new RuntimeException("not supported os");
//     }
//     
//     public void refreshDeviceList() {
//         proxy.refreshDeviceList();
//     }
//     
//     public PortableDevice[] getDevices() {
//         return proxy.getDevices();
//     }
// 
//     public Iterator<PortableDevice> iterator() {
//         return proxy.iterator();
//     }
// }
// 
// Path: source/java/src/jmtp/PortableDeviceObject.java
// public interface PortableDeviceObject {
//     
// 	public String getID();
// 	public String getName();
//     public String getOriginalFileName();
//     public boolean canDelete();
//     public boolean isHidden();
//     public boolean isSystemObject();
//     public boolean isDrmProtected();
//     public Date getDateModified();
//     public Date getDateCreated();
//     public Date getDateAuthored();
//     public PortableDeviceObject getParent();
//     public BigInteger getSize();
//     public String getPersistentUniqueIdentifier();
//     public String getSyncID();
//     public Guid getFormat();
//     
//     public void setSyncID(String value);	//TODO nog een exception kunnen gooien
//     
//     public void delete();
// }


// Path: utils/MTPUtil.java
import java.util.ArrayList;
import de.aok.no.kopra.agnes.desktop.util.LogUtil;
import jmtp.PortableDevice;
import jmtp.PortableDeviceFolderObject;
import jmtp.PortableDeviceManager;
import jmtp.PortableDeviceObject;
import jmtp.PortableDeviceStorageObject;


	private static PortableDeviceFolderObject getChildByName(PortableDeviceFolderObject folder, String z) {
		for (PortableDeviceObject object : folder.getChildObjects()) {
			if (object.getOriginalFileName().equals(z)) {
				LogUtil.debugPrint(LogUtil.LOG_LEVEL_FULL,MTPUtil.class.getSimpleName(),  "Found directory " + z);
				return (PortableDeviceFolderObject) object;
			}
		}
		return null;
	}

	private static PortableDeviceObject getChildByName(PortableDeviceStorageObject storage, String z) {
		for (PortableDeviceObject object : storage.getChildObjects()) {
			if (object.getOriginalFileName().equals(z)) {
				LogUtil.debugPrint(LogUtil.LOG_LEVEL_FULL, MTPUtil.class.getSimpleName(),  "Found directory " + z);
				return object;
			}
		}
		return null;
	}

	public static PortableDevice[] getDevices() {
		PortableDeviceManager manager = new PortableDeviceManager();
		manager.refreshDeviceList();
		return manager.getDevices();
	}

	public static void printDevices() {
		PortableDeviceManager manager = new PortableDeviceManager();

		manager.refreshDeviceList();