package com.omnicore.nativeinterface.win32; import com.omnicore.nativeinterface.win32.registry.Win32RegistryInterface; import com.omnicore.vcs.api.registry.*; import java.util.*; // Referenced classes of package com.omnicore.nativeinterface.win32: // Win32MailSlotInterface, Win32EventsInterface, Win32MouseWheelListener public class Win32Interface { Win32Interface() { listener = null; String ucOsName = System.getProperty("os.name").toUpperCase(Locale.US); if(ucOsName.matches("WINDOWS +(95|98|ME).*")) { registryInterface = null; mailSlotInterface = null; eventsInterface = null; } else { registryInterface = new Win32RegistryInterface(); } } public Win32EventsInterface getEventsInterface() { return eventsInterface; } public Win32MailSlotInterface getMailSlotInterface() { return mailSlotInterface; } public static synchronized Win32Interface getInterface() { if(instance != null) return instance; if(System.getProperty("os.name").indexOf("Windows") == -1) return null; try { System.loadLibrary("winsupport"); instance = new Win32Interface(); instance.startCaptureWheelMessagesImpl(); return instance; } catch(Throwable e) { instance = null; } return null; } public Win32RegistryInterface getRegistryInterface() { return registryInterface; } public String getBrowser() { if(registryInterface == null) return null; com.omnicore.vcs.api.registry.WindowsRegistryHandle rootKey = registryInterface.getPredefinedKeyHandle(WindowsRegistryPredefinedHandle.HKEY_CLASSES_ROOT); com.omnicore.vcs.api.registry.WindowsRegistryHandle key = registryInterface.openKey(rootKey, "HTTP\\SHELL\\OPEN\\COMMAND", WindowsRegistryAccessRights.KEY_READ); String browser = null; if(key != null) { WindowsRegistryValue value = registryInterface.getDefaultValue(key, true); if(value != null) browser = value.getValueAsString(); registryInterface.disposeKeyHandle(key); } if(browser != null && !browser.equals("")) { int exeIndex = browser.toUpperCase(Locale.US).indexOf(".EXE"); if(exeIndex != -1) { browser = browser.substring(0, exeIndex + 4); browser = browser.replace('"', ' ').trim(); return browser; } } return null; } public String[] getJavaHomes() { if(registryInterface == null) return new String[0]; com.omnicore.vcs.api.registry.WindowsRegistryHandle rootKey = registryInterface.getPredefinedKeyHandle(WindowsRegistryPredefinedHandle.HKEY_LOCAL_MACHINE); com.omnicore.vcs.api.registry.WindowsRegistryHandle key = registryInterface.openKey(rootKey, "Software\\JavaSoft\\Java Development Kit", WindowsRegistryAccessRights.KEY_READ); Set javaHomes = new HashSet(); if(key != null) { String subKeyNames[] = registryInterface.enumerateSubkeys(key); String as[] = subKeyNames; for(int i = 0; i < as.length; i++) { String subKeyName = as[i]; com.omnicore.vcs.api.registry.WindowsRegistryHandle subKey = registryInterface.openKey(key, subKeyName, WindowsRegistryAccessRights.KEY_READ); if(subKey != null) { WindowsRegistryValue value = registryInterface.getValue(subKey, "JavaHome", true); if(value != null && value.getValueAsString() != null && value.getValueAsString().length() > 0) javaHomes.add(value.getValueAsString()); registryInterface.disposeKeyHandle(subKey); } } registryInterface.disposeKeyHandle(key); } String result[] = new String[javaHomes.size()]; javaHomes.toArray(result); return result; } private synchronized void onWheelMoved(int move, int x, int y, int mask) { if(listener != null) listener.mouseWheelMoved(move, x, y, mask); } public void setMouseWheelListener(Win32MouseWheelListener listener) { this.listener = listener; } public int getDaysOfUse(byte ch) { return 5; } public String getUserProfileDirectory() { return System.getenv("USERPROFILE"); } private native void startCaptureWheelMessagesImpl(); private native void stopCaptureWheelMessagesImpl(); private native int getDaysOfUseImpl(byte byte0); private static Win32Interface instance; private static final boolean DEBUG = false; private static final String NATIVE_JAR_FILENAME = "native.jar"; private static final String LIBARARY_NAME = "winsupport"; private Win32MouseWheelListener listener; private final Win32RegistryInterface registryInterface; private final Win32MailSlotInterface mailSlotInterface = new Win32MailSlotInterface(); private final Win32EventsInterface eventsInterface = new Win32EventsInterface(); }