diff --git a/app/src/processing/app/windows/Advapi32.java b/app/src/processing/app/windows/Advapi32.java deleted file mode 100644 index 716983ea3..000000000 --- a/app/src/processing/app/windows/Advapi32.java +++ /dev/null @@ -1,335 +0,0 @@ -package processing.app.windows; - -/* - * Advapi32.java - * - * Created on 6. August 2007, 11:24 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -import com.sun.jna.*; -import com.sun.jna.ptr.*; -import com.sun.jna.win32.*; - -/** - * - * @author TB - */ -public interface Advapi32 extends StdCallLibrary { - Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS); //$NON-NLS-1$ - -/* -BOOL WINAPI LookupAccountName( - LPCTSTR lpSystemName, - LPCTSTR lpAccountName, - PSID Sid, - LPDWORD cbSid, - LPTSTR ReferencedDomainName, - LPDWORD cchReferencedDomainName, - PSID_NAME_USE peUse -);*/ - public boolean LookupAccountName(String lpSystemName, String lpAccountName, - byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName, - IntByReference cchReferencedDomainName, PointerByReference peUse); - -/* -BOOL WINAPI LookupAccountSid( - LPCTSTR lpSystemName, - PSID lpSid, - LPTSTR lpName, - LPDWORD cchName, - LPTSTR lpReferencedDomainName, - LPDWORD cchReferencedDomainName, - PSID_NAME_USE peUse -);*/ - public boolean LookupAccountSid(String lpSystemName, byte[] Sid, - char[] lpName, IntByReference cchName, char[] ReferencedDomainName, - IntByReference cchReferencedDomainName, PointerByReference peUse); - -/* -BOOL ConvertSidToStringSid( - PSID Sid, - LPTSTR* StringSid -);*/ - public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid); - -/* -BOOL WINAPI ConvertStringSidToSid( - LPCTSTR StringSid, - PSID* Sid -);*/ - public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid); - -/* -SC_HANDLE WINAPI OpenSCManager( - LPCTSTR lpMachineName, - LPCTSTR lpDatabaseName, - DWORD dwDesiredAccess -);*/ - public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess); - -/* -BOOL WINAPI CloseServiceHandle( - SC_HANDLE hSCObject -);*/ - public boolean CloseServiceHandle(Pointer hSCObject); - -/* -SC_HANDLE WINAPI OpenService( - SC_HANDLE hSCManager, - LPCTSTR lpServiceName, - DWORD dwDesiredAccess -);*/ - public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess); - -/* -BOOL WINAPI StartService( - SC_HANDLE hService, - DWORD dwNumServiceArgs, - LPCTSTR* lpServiceArgVectors -);*/ - public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors); - -/* -BOOL WINAPI ControlService( - SC_HANDLE hService, - DWORD dwControl, - LPSERVICE_STATUS lpServiceStatus -);*/ - public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus); - -/* -BOOL WINAPI StartServiceCtrlDispatcher( - const SERVICE_TABLE_ENTRY* lpServiceTable -);*/ - public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable); - -/* -SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler( - LPCTSTR lpServiceName, - LPHANDLER_FUNCTION lpHandlerProc -);*/ - public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc); - -/* -SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx( - LPCTSTR lpServiceName, - LPHANDLER_FUNCTION_EX lpHandlerProc, - LPVOID lpContext -);*/ - public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext); - -/* -BOOL WINAPI SetServiceStatus( - SERVICE_STATUS_HANDLE hServiceStatus, - LPSERVICE_STATUS lpServiceStatus -);*/ - public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus); - -/* -SC_HANDLE WINAPI CreateService( - SC_HANDLE hSCManager, - LPCTSTR lpServiceName, - LPCTSTR lpDisplayName, - DWORD dwDesiredAccess, - DWORD dwServiceType, - DWORD dwStartType, - DWORD dwErrorControl, - LPCTSTR lpBinaryPathName, - LPCTSTR lpLoadOrderGroup, - LPDWORD lpdwTagId, - LPCTSTR lpDependencies, - LPCTSTR lpServiceStartName, - LPCTSTR lpPassword -);*/ - public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName, - int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl, - String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId, - String lpDependencies, String lpServiceStartName, String lpPassword); - -/* -BOOL WINAPI DeleteService( - SC_HANDLE hService -);*/ - public boolean DeleteService(Pointer hService); - -/* -BOOL WINAPI ChangeServiceConfig2( - SC_HANDLE hService, - DWORD dwInfoLevel, - LPVOID lpInfo -);*/ - public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo); - -/* -LONG WINAPI RegOpenKeyEx( - HKEY hKey, - LPCTSTR lpSubKey, - DWORD ulOptions, - REGSAM samDesired, - PHKEY phkResult -);*/ - public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult); - -/* -LONG WINAPI RegQueryValueEx( - HKEY hKey, - LPCTSTR lpValueName, - LPDWORD lpReserved, - LPDWORD lpType, - LPBYTE lpData, - LPDWORD lpcbData -);*/ - public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData); - -/* -LONG WINAPI RegCloseKey( - HKEY hKey -);*/ - public int RegCloseKey(int hKey); - -/* -LONG WINAPI RegDeleteValue( - HKEY hKey, - LPCTSTR lpValueName -);*/ - public int RegDeleteValue(int hKey, String lpValueName); - -/* -LONG WINAPI RegSetValueEx( - HKEY hKey, - LPCTSTR lpValueName, - DWORD Reserved, - DWORD dwType, - const BYTE* lpData, - DWORD cbData -);*/ - public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData); - -/* -LONG WINAPI RegCreateKeyEx( - HKEY hKey, - LPCTSTR lpSubKey, - DWORD Reserved, - LPTSTR lpClass, - DWORD dwOptions, - REGSAM samDesired, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - PHKEY phkResult, - LPDWORD lpdwDisposition -);*/ - public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions, - int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult, - IntByReference lpdwDisposition); - -/* -LONG WINAPI RegDeleteKey( - HKEY hKey, - LPCTSTR lpSubKey -);*/ - public int RegDeleteKey(int hKey, String name); - -/* -LONG WINAPI RegEnumKeyEx( - HKEY hKey, - DWORD dwIndex, - LPTSTR lpName, - LPDWORD lpcName, - LPDWORD lpReserved, - LPTSTR lpClass, - LPDWORD lpcClass, - PFILETIME lpftLastWriteTime -);*/ - public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved, - char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime); - -/* -LONG WINAPI RegEnumValue( - HKEY hKey, - DWORD dwIndex, - LPTSTR lpValueName, - LPDWORD lpcchValueName, - LPDWORD lpReserved, - LPDWORD lpType, - LPBYTE lpData, - LPDWORD lpcbData -);*/ - public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved, - IntByReference lpType, byte[] lpData, IntByReference lpcbData); - - interface SERVICE_MAIN_FUNCTION extends StdCallCallback { - /* - VOID WINAPI ServiceMain( - DWORD dwArgc, - LPTSTR* lpszArgv - );*/ - public void callback(int dwArgc, Pointer lpszArgv); - } - - interface Handler extends StdCallCallback { - /* - VOID WINAPI Handler( - DWORD fdwControl - );*/ - public void callback(int fdwControl); - } - - interface HandlerEx extends StdCallCallback { - /* - DWORD WINAPI HandlerEx( - DWORD dwControl, - DWORD dwEventType, - LPVOID lpEventData, - LPVOID lpContext - );*/ - public void callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext); - } - -/* -typedef struct _SERVICE_STATUS { - DWORD dwServiceType; - DWORD dwCurrentState; - DWORD dwControlsAccepted; - DWORD dwWin32ExitCode; - DWORD dwServiceSpecificExitCode; - DWORD dwCheckPoint; - DWORD dwWaitHint; -} SERVICE_STATUS, - *LPSERVICE_STATUS;*/ - public static class SERVICE_STATUS extends Structure { - public int dwServiceType; - public int dwCurrentState; - public int dwControlsAccepted; - public int dwWin32ExitCode; - public int dwServiceSpecificExitCode; - public int dwCheckPoint; - public int dwWaitHint; - } - -/* -typedef struct _SERVICE_TABLE_ENTRY { - LPTSTR lpServiceName; - LPSERVICE_MAIN_FUNCTION lpServiceProc; -} SERVICE_TABLE_ENTRY, - *LPSERVICE_TABLE_ENTRY;*/ - public static class SERVICE_TABLE_ENTRY extends Structure { - public String lpServiceName; - public SERVICE_MAIN_FUNCTION lpServiceProc; - } - - public static class ChangeServiceConfig2Info extends Structure { - } - -/* - typedef struct _SERVICE_DESCRIPTION { - LPTSTR lpDescription; -} SERVICE_DESCRIPTION, - *LPSERVICE_DESCRIPTION;*/ - public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info { - public String lpDescription; - } -} - - diff --git a/app/src/processing/app/windows/Options.java b/app/src/processing/app/windows/Options.java deleted file mode 100644 index f5cff2888..000000000 --- a/app/src/processing/app/windows/Options.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Options.java - * - * Created on 8. August 2007, 17:07 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package processing.app.windows; - -import static com.sun.jna.Library.*; -import com.sun.jna.win32.*; -import java.util.*; - -/** - * - * @author TB - */ -public interface Options { - Map UNICODE_OPTIONS = new HashMap() { - { - put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); - put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE); - } - }; -} diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java index a6c228f17..c5325fb17 100644 --- a/app/src/processing/app/windows/Platform.java +++ b/app/src/processing/app/windows/Platform.java @@ -3,13 +3,12 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2012 The Processing Foundation + Copyright (c) 2012-2013 The Processing Foundation Copyright (c) 2008-2012 Ben Fry and Casey Reas - This program 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. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,16 +23,20 @@ package processing.app.windows; import java.io.File; +import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; import com.sun.jna.Library; import com.sun.jna.Native; -import com.sun.jna.NativeMapped; -import com.sun.jna.PointerType; -import com.sun.jna.win32.W32APIFunctionMapper; -import com.sun.jna.win32.W32APITypeMapper; +import com.sun.jna.WString; +import com.sun.jna.platform.win32.Kernel32Util; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.ShellAPI; +import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT; +import com.sun.jna.platform.win32.ShlObj; +import com.sun.jna.platform.win32.WinDef; +import com.sun.jna.platform.win32.WinError; +import com.sun.jna.platform.win32.WinNT.HRESULT; import processing.app.Base; import processing.app.Preferences; @@ -41,13 +44,28 @@ import processing.app.windows.Registry.REGISTRY_ROOT_KEY; import processing.core.PApplet; +/** + * Platform-specific glue for Windows. + * + * This is a bit of a hodgepodge of JNA examples and StackOverflow answers, + * and as a result, is not the prettiest piece of code in this code base. + * In fact, an honest man might call it ugly. + * + * Classes like Advapi32, WINNT, etc could be removed in favor of the + * jna-platform.jar, but that would require 1) some cleanup and extensive + * testing (across Windows XP, 7, and 8) to make sure everything was still + * working. It would also require adding the new .jar file, and making sure + * that it was included with the distribution across all of the platforms. + */ public class Platform extends processing.app.Platform { - + static final String openCommand = System.getProperty("user.dir").replace('/', '\\') + "\\processing.exe \"%1\""; static final String DOC = "Processing.Document"; // static final String DOC = "Processing.exe"; + + static final String APP_NAME = "Processing"; public void init(Base base) { @@ -56,6 +74,16 @@ public class Platform extends processing.app.Platform { //checkQuickTime(); checkPath(); + /* + File f = new File("C:\\recycle-test.txt"); + System.out.println(f.getAbsolutePath()); + java.io.PrintWriter writer = PApplet.createWriter(f); + writer.println("blah"); + writer.flush(); + writer.close(); + deleteFile(f); + */ + //findJDK(); /* new Thread(new Runnable() { @@ -173,34 +201,6 @@ public class Platform extends processing.app.Platform { } - /** - * Find QuickTime for Java installation. - */ -// protected void checkQuickTime() { -// // http://developer.apple.com/documentation/QuickTime/Conceptual/QT7Win_Update_Guide/Chapter03/chapter_3_section_1.html -// // HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\QuickTime\QTSysDir -// try { -// String qtsystemPath = -// Registry.getStringValue(REGISTRY_ROOT_KEY.LOCAL_MACHINE, -// "Software\\Apple Computer, Inc.\\QuickTime", -// "QTSysDir"); -// // Could show a warning message here if QT not installed, but that -// // would annoy people who don't want anything to do with QuickTime. -// if (qtsystemPath != null) { -// File qtjavaZip = new File(qtsystemPath, "QTJava.zip"); -// if (qtjavaZip.exists()) { -// String qtjavaZipPath = qtjavaZip.getAbsolutePath(); -// String cp = System.getProperty("java.class.path"); -// System.setProperty("java.class.path", -// cp + File.pathSeparator + qtjavaZipPath); -// } -// } -// } catch (UnsupportedEncodingException e) { -// e.printStackTrace(); -// } -// } - - /** * Remove extra quotes, slashes, and garbage from the Windows PATH. */ @@ -238,6 +238,15 @@ public class Platform extends processing.app.Platform { // looking for Documents and Settings/blah/Application Data/Processing public File getSettingsFolder() throws Exception { + String appData = getAppDataPath(); + if (appData != null) { + return new File(appData, APP_NAME); + } + return null; + } + + + static private String getAppDataPath() throws Exception { // HKEY_CURRENT_USER\Software\Microsoft // \Windows\CurrentVersion\Explorer\Shell Folders // Value Name: AppData @@ -254,26 +263,37 @@ public class Platform extends processing.app.Platform { // Java 1.6 doesn't provide a good workaround (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127) // Using JNA and SHGetFolderPath instead. - char[] pszPath = new char[Shell32.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful - int hResult = Shell32.INSTANCE.SHGetFolderPath(null, Shell32.CSIDL_APPDATA, null, Shell32.SHGFP_TYPE_CURRENT, pszPath); + // this will be contain the path if SHGetFolderPath is successful + char[] pszPath = new char[WinDef.MAX_PATH]; + HRESULT hResult = + Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_APPDATA, + null, ShlObj.SHGFP_TYPE_CURRENT, + pszPath); - if (Shell32.S_OK != hResult){ - throw new Exception("Problem city, population your computer"); + if (!hResult.equals(WinError.S_OK)) { + System.err.println(Kernel32Util.formatMessageFromHR(hResult)); + throw new Exception("Problem city, population: your computer."); } String appDataPath = new String(pszPath); int len = appDataPath.indexOf("\0"); - appDataPath = appDataPath.substring(0, len); - - // DEBUG - //throw new Exception("win: " + appDataPath); - return new File(appDataPath, "Processing"); +// appDataPath = appDataPath.substring(0, len); +// return new File(appDataPath, "Processing"); + return appDataPath.substring(0, len); } // looking for Documents and Settings/blah/My Documents/Processing public File getDefaultSketchbookFolder() throws Exception { + String documentsPath = getDocumentsPath(); + if (documentsPath != null) { + return new File(documentsPath, APP_NAME); + } + return null; + } + + static private String getDocumentsPath() throws Exception { // http://support.microsoft.com/?kbid=221837&sd=RMVP // http://support.microsoft.com/kb/242557/en-us @@ -297,22 +317,110 @@ public class Platform extends processing.app.Platform { // "The "Shell Folders" key exists solely to permit four programs written // in 1994 to continue running on the RTM version of Windows 95." -- Raymond Chen, MSDN - char[] pszPath = new char[Shell32.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful - int hResult = Shell32.INSTANCE.SHGetFolderPath(null, Shell32.CSIDL_PERSONAL, null, Shell32.SHGFP_TYPE_CURRENT, pszPath); + char[] pszPath = new char[WinDef.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful + HRESULT hResult = Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_PERSONAL, null, ShlObj.SHGFP_TYPE_CURRENT, pszPath); - if (Shell32.S_OK != hResult){ - throw new Exception("Problem city, population your computer"); + if (!hResult.equals(WinError.S_OK)) { + System.err.println(Kernel32Util.formatMessageFromHR(hResult)); + throw new Exception("Problem city, population: your computer."); } String personalPath = new String(pszPath); int len = personalPath.indexOf("\0"); - personalPath = personalPath.substring(0, len); - - // DEBUG - //throw new Exception("win: " + personalPath); - return new File(personalPath, "Processing"); +// personalPath = personalPath.substring(0, len); +// return new File(personalPath, "Processing"); + return personalPath.substring(0, len); } - + + + @Override + public boolean deleteFile(File file) { + try { + moveToTrash(new File[] { file }); + } catch (IOException e) { + e.printStackTrace(); + Base.log("Could not move " + file.getAbsolutePath() + " to the trash.", e); + return false; + } + return true; + } + + + /** + * Move files/folders to the trash. If this file is on another file system + * or on a shared network directory, it will simply be deleted without any + * additional confirmation. Take that. + *

+ * Based on JNA source for com.sun.jna.platform.win32.W32FileUtils + * + * @param files array of File objects to be removed + * @return true if no error codes returned + * @throws IOException if something bad happened along the way + */ + static private boolean moveToTrash(File[] files) throws IOException { + Shell32 shell = Shell32.INSTANCE; + SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT(); + fileop.wFunc = ShellAPI.FO_DELETE; + String[] paths = new String[files.length]; + for (int i = 0; i < paths.length; i++) { + paths[i] = files[i].getAbsolutePath(); + System.out.println(paths[i]); + } + fileop.pFrom = new WString(fileop.encodePaths(paths)); + fileop.fFlags = ShellAPI.FOF_ALLOWUNDO | ShellAPI.FOF_NO_UI; + int ret = shell.SHFileOperation(fileop); + if (ret != 0) { + throw new IOException("Move to trash failed: " + + fileop.pFrom + ": error code " + ret); +// throw new IOException("Move to trash failed: " + fileop.pFrom + ": " + +// Kernel32Util.formatMessageFromLastErrorCode(ret)); + } + if (fileop.fAnyOperationsAborted) { + throw new IOException("Move to trash aborted"); + } + return true; + } + + +// /** +// * Ported from ShellAPI.h in the Microsoft Windows SDK 6.0A. +// * Modified (bastardized) version from the JNA "platform" classes. +// * @author dblock[at]dblock.org +// */ +// public interface ShellAPI extends StdCallLibrary { +// +// int STRUCTURE_ALIGNMENT = com.sun.jna.Platform.is64Bit() ? +// Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE; +// +// int FO_MOVE = 0x0001; +// int FO_COPY = 0x0002; +// int FO_DELETE = 0x0003; +// int FO_RENAME = 0x0004; +// +// int FOF_MULTIDESTFILES = 0x0001; +// int FOF_CONFIRMMOUSE = 0x0002; +// int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still) +// int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions +// int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not +// int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings +// int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete() +// int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this +// int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files +// int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases +// int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations +// int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs) +// int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse +// int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files) +// int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION) +// int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts) +// int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all +// +// int PO_DELETE = 0x0013; // printer is being deleted +// int PO_RENAME = 0x0014; // printer is being renamed +// int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed +// int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time. +// } + /* public void openURL(String url) throws Exception { @@ -399,46 +507,59 @@ public class Platform extends processing.app.Platform { return clib._putenv(variable + "="); } + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // JNA code for using SHGetFolderPath to fix Issue 410 + // https://code.google.com/p/processing/issues/detail?id=410 // Based on answer provided by McDowell at - // http://stackoverflow.com/questions/585534/ - // what-is-the-best-way-to-find-the-users-home-directory-in-java/586917#586917 - - private static Map OPTIONS = new HashMap(); - - static{ - OPTIONS.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); - OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE); - } - - static class HANDLE extends PointerType implements NativeMapped{} - - static class HWND extends HANDLE {} - - public interface Shell32 extends Library{ - - public static final int MAX_PATH = 260; - public static final int SHGFP_TYPE_CURRENT = 0; - public static final int SHGFP_TYPE_DEFAULT = 1; - public static final int S_OK = 0; - - // KNOWNFOLDERIDs are preferred to CSDIL values - // but Windows XP only supports CSDIL so thats what we have to use - public static final int CSIDL_APPDATA = 0x001a; // "Application Data" - public static final int CSIDL_PERSONAL = 0x0005; // "My Documents" - - static Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class, OPTIONS); - - /** - * see http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx - * - * HRESULT SHGetFolderPath( HWND hwndOwner, int nFolder, HANDLE hToken, - * DWORD dwFlags, LPTSTR pszPath); - */ - public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, - int dwFlags, char[] pszPath); - } + // http://stackoverflow.com/questions/585534/what-is-the-best-way-to-find-the-users-home-directory-in-java/586917#586917 +// private static Map OPTIONS = new HashMap(); +// +// static { +// OPTIONS.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); +// OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE); +// } +// +// +// static class HANDLE extends PointerType implements NativeMapped { +// public HANDLE() { } +// } +// +// static class HWND extends HANDLE { } +// +// +// public interface Shell32 extends Library { +// +// public static final int MAX_PATH = 260; +// public static final int SHGFP_TYPE_CURRENT = 0; +// public static final int SHGFP_TYPE_DEFAULT = 1; +// public static final int S_OK = 0; +// +// // KNOWNFOLDERIDs are preferred to CSDIL values +// // but Windows XP only supports CSDIL so thats what we have to use +// public static final int CSIDL_APPDATA = 0x001a; // "Application Data" +// public static final int CSIDL_PERSONAL = 0x0005; // "My Documents" +// +// static Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class, OPTIONS); +// +// /** +// * see http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx +// * +// * HRESULT SHGetFolderPath( HWND hwndOwner, int nFolder, HANDLE hToken, +// * DWORD dwFlags, LPTSTR pszPath); +// */ +// public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, +// int dwFlags, char[] pszPath); +// +// /** +// * This function can be used to copy, move, rename, +// * or delete a file system object. +// * @param fileop Address of an SHFILEOPSTRUCT structure that contains +// * information this function needs to carry out the specified operation. +// * @return Returns zero if successful, or nonzero otherwise. +// */ +// public int SHFileOperation(SHFILEOPSTRUCT fileop); +// } } diff --git a/app/src/processing/app/windows/Registry.java b/app/src/processing/app/windows/Registry.java index dcb719ef8..5509ca481 100644 --- a/app/src/processing/app/windows/Registry.java +++ b/app/src/processing/app/windows/Registry.java @@ -5,42 +5,61 @@ import java.util.HashMap; import java.util.TreeMap; import java.util.TreeSet; +import com.sun.jna.platform.win32.Advapi32; +import com.sun.jna.platform.win32.WinBase; +import com.sun.jna.platform.win32.WinError; +import com.sun.jna.platform.win32.WinNT; +import com.sun.jna.platform.win32.WinReg; +import com.sun.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.ptr.IntByReference; + /** - * Methods for accessing the Windows Registry. Only String and DWORD values supported at the moment. + * Methods for accessing the Windows Registry. Only String and DWORD values + * supported at the moment. + *

+ * Not sure of where this code came from originally, but it was hacked on + * 20 July 2013 to make updates for use with JNA 3.5.2's platform classes. */ public class Registry { - public static enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS}; - private final static HashMap rootKeyMap = new HashMap(); + static public enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS}; + //private final static HashMap rootKeyMap = new HashMap(); + private final static HashMap rootKeyMap = + new HashMap(); static { - rootKeyMap.put(REGISTRY_ROOT_KEY.CLASSES_ROOT, WINREG.HKEY_CLASSES_ROOT); - rootKeyMap.put(REGISTRY_ROOT_KEY.CURRENT_USER, WINREG.HKEY_CURRENT_USER); - rootKeyMap.put(REGISTRY_ROOT_KEY.LOCAL_MACHINE, WINREG.HKEY_LOCAL_MACHINE); - rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS); + rootKeyMap.put(REGISTRY_ROOT_KEY.CLASSES_ROOT, WinReg.HKEY_CLASSES_ROOT); + rootKeyMap.put(REGISTRY_ROOT_KEY.CURRENT_USER, WinReg.HKEY_CURRENT_USER); + rootKeyMap.put(REGISTRY_ROOT_KEY.LOCAL_MACHINE, WinReg.HKEY_LOCAL_MACHINE); + rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WinReg.HKEY_USERS); } + /** * Gets one of the root keys. * * @param key key type * @return root key */ - private static int getRegistryRootKey(REGISTRY_ROOT_KEY key) { + private static HKEY getRegistryRootKey(REGISTRY_ROOT_KEY key) { Advapi32 advapi32; - IntByReference pHandle; - int handle = 0; + //IntByReference pHandle; + HKEYByReference pHandle; + //int handle = 0; + HKEY handle = null; advapi32 = Advapi32.INSTANCE; - pHandle = new IntByReference(); +// pHandle = new IntByReference(); + pHandle = new WinReg.HKEYByReference(); - if(advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WINERROR.ERROR_SUCCESS) { + if (advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WinError.ERROR_SUCCESS) { handle = pHandle.getValue(); } - return(handle); + return handle; } + /** * Opens a key. * @@ -49,23 +68,24 @@ public class Registry { * @param access access mode * @return handle to the key or 0 */ - private static int openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access) { - Advapi32 advapi32; - IntByReference pHandle; - int rootKeyHandle; + private static HKEY openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access) { + //Advapi32 advapi32; + //IntByReference pHandle; + //int rootKeyHandle; - advapi32 = Advapi32.INSTANCE; - rootKeyHandle = getRegistryRootKey(rootKey); - pHandle = new IntByReference(); - - if(advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WINERROR.ERROR_SUCCESS) { - return(pHandle.getValue()); + Advapi32 advapi32 = Advapi32.INSTANCE; + HKEY rootKeyHandle = getRegistryRootKey(rootKey); + //pHandle = new IntByReference(); + HKEYByReference pHandle = new HKEYByReference(); + if (advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WinError.ERROR_SUCCESS) { + return pHandle.getValue(); } else { - return(0); + return null; } } + /** * Converts a Windows buffer to a Java String. * @@ -74,9 +94,10 @@ public class Registry { * @return String */ private static String convertBufferToString(byte[] buf) throws UnsupportedEncodingException { - return(new String(buf, 0, buf.length - 2, "UTF-16LE")); + return new String(buf, 0, buf.length - 2, "UTF-16LE"); } + /** * Converts a Windows buffer to an int. * @@ -84,9 +105,13 @@ public class Registry { * @return int */ private static int convertBufferToInt(byte[] buf) { - return((buf[0] & 0xff) + ((buf[1] & 0xff) << 8) + ((buf[2] & 0xff) << 16) + ((buf[3] & 0xff) << 24)); + return ((buf[0] & 0xff) + + ((buf[1] & 0xff) << 8) + + ((buf[2] & 0xff) << 16) + + ((buf[3] & 0xff) << 24)); } + /** * Read a String value. * @@ -96,32 +121,35 @@ public class Registry { * @throws java.io.UnsupportedEncodingException on error * @return String or null */ - public static String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException { - Advapi32 advapi32; - IntByReference pType, lpcbData; + static public String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException { + //Advapi32 advapi32; + //IntByReference pType, lpcbData; byte[] lpData = new byte[1]; - int handle = 0; + //int handle = 0; String ret = null; - advapi32 = Advapi32.INSTANCE; - pType = new IntByReference(); - lpcbData = new IntByReference(); - handle = openKey(rootKey, subKeyName, WINNT.KEY_READ); + Advapi32 advapi32 = Advapi32.INSTANCE; + IntByReference pType = new IntByReference(); + IntByReference lpcbData = new IntByReference(); + HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ); - if(handle != 0) { - - if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) { + //if (handle != 0) { + if (handle != null) { + //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) { + if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) { lpData = new byte[lpcbData.getValue()]; - if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) { + //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) { + if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) { ret = convertBufferToString(lpData); } } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Read an int value. * @@ -131,32 +159,37 @@ public class Registry { * @param subKeyName key name * @param name value name */ - public static int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) { + static public int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) { Advapi32 advapi32; - IntByReference pType, lpcbData; + IntByReference pType; + IntByReference lpcbData; byte[] lpData = new byte[1]; - int handle = 0; + //int handle = 0; + HKEY handle = null; int ret = 0; advapi32 = Advapi32.INSTANCE; pType = new IntByReference(); lpcbData = new IntByReference(); - handle = openKey(rootKey, subKeyName, WINNT.KEY_READ); + handle = openKey(rootKey, subKeyName, WinNT.KEY_READ); - if(handle != 0) { - - if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) { + //if(handle != 0) { + if (handle != null) { + //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) { + if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_MORE_DATA) { lpData = new byte[lpcbData.getValue()]; - if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) { + //if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) { + if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) == WinError.ERROR_SUCCESS) { ret = convertBufferToInt(lpData); } } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Delete a value. * @@ -165,24 +198,24 @@ public class Registry { * @param name value name * @return true on success */ - public static boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) { - Advapi32 advapi32; - int handle; + static public boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) { + Advapi32 advapi32 = Advapi32.INSTANCE; + //int handle; boolean ret = true; - advapi32 = Advapi32.INSTANCE; + HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE); - handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE); - - if(handle != 0) { - if(advapi32.RegDeleteValue(handle, name) == WINERROR.ERROR_SUCCESS) { + //if(handle != 0) { + if (handle != null) { + if (advapi32.RegDeleteValue(handle, name) == WinError.ERROR_SUCCESS) { ret = true; } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Writes a String value. * @@ -193,9 +226,8 @@ public class Registry { * @throws java.io.UnsupportedEncodingException on error * @return true on success */ - public static boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException { - Advapi32 advapi32; - int handle; + static public boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException { + //int handle; byte[] data; boolean ret = false; @@ -205,18 +237,20 @@ public class Registry { byte[] src = value.getBytes("UTF-16LE"); System.arraycopy(src, 0, data, 0, src.length); - advapi32 = Advapi32.INSTANCE; - handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE); + Advapi32 advapi32 = Advapi32.INSTANCE; + HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE); - if(handle != 0) { - if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_SZ, data, data.length) == WINERROR.ERROR_SUCCESS) { + //if(handle != 0) { + if (handle != null) { + if (advapi32.RegSetValueEx(handle, name, 0, WinNT.REG_SZ, data, data.length) == WinError.ERROR_SUCCESS) { ret = true; } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Writes an int value. * @@ -227,9 +261,9 @@ public class Registry { * @param name value name * @param value value */ - public static boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) { + static public boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) { Advapi32 advapi32; - int handle; + //int handle; byte[] data; boolean ret = false; @@ -239,18 +273,19 @@ public class Registry { data[2] = (byte)((value >> 16) & 0xff); data[3] = (byte)((value >> 24) & 0xff); advapi32 = Advapi32.INSTANCE; - handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE); + HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ | WinNT.KEY_WRITE); - if(handle != 0) { - - if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_DWORD, data, data.length) == WINERROR.ERROR_SUCCESS) { + //if(handle != 0) { + if (handle != null) { + if (advapi32.RegSetValueEx(handle, name, 0, WinNT.REG_DWORD, data, data.length) == WinError.ERROR_SUCCESS) { ret = true; } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Check for existence of a value. * @@ -259,21 +294,22 @@ public class Registry { * @param name value name * @return true if exists */ - public static boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) { - Advapi32 advapi32; + static public boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) { + //Advapi32 advapi32; IntByReference pType, lpcbData; byte[] lpData = new byte[1]; - int handle = 0; + //int handle = 0; boolean ret = false; - advapi32 = Advapi32.INSTANCE; + Advapi32 advapi32 = Advapi32.INSTANCE; pType = new IntByReference(); lpcbData = new IntByReference(); - handle = openKey(rootKey, subKeyName, WINNT.KEY_READ); + HKEY handle = openKey(rootKey, subKeyName, WinNT.KEY_READ); - if(handle != 0) { - - if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WINERROR.ERROR_FILE_NOT_FOUND) { + //if(handle != 0) { + if (handle != null) { + //if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WinError.ERROR_FILE_NOT_FOUND) { + if (advapi32.RegQueryValueEx(handle, name, 0, pType, lpData, lpcbData) != WinError.ERROR_FILE_NOT_FOUND) { ret = true; } else { @@ -281,9 +317,10 @@ public class Registry { } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Create a new key. * @@ -292,21 +329,22 @@ public class Registry { * @param name key name * @return true on success */ - public static boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) { - Advapi32 advapi32; - IntByReference hkResult, dwDisposition; - int handle = 0; + static public boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) { + //Advapi32 advapi32; + //IntByReference hkResult, dwDisposition; + //int handle = 0; boolean ret = false; - advapi32 = Advapi32.INSTANCE; - hkResult = new IntByReference(); - dwDisposition = new IntByReference(); - handle = openKey(rootKey, parent, WINNT.KEY_READ); + Advapi32 advapi32 = Advapi32.INSTANCE; + //IntByReference hkResult = new IntByReference(); + HKEYByReference hkResult = new HKEYByReference(); + IntByReference dwDisposition = new IntByReference(); + HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ); - if(handle != 0) { - - if(advapi32.RegCreateKeyEx(handle, name, 0, null, WINNT.REG_OPTION_NON_VOLATILE, WINNT.KEY_READ, null, - hkResult, dwDisposition) == WINERROR.ERROR_SUCCESS) { + //if(handle != 0) { + if (handle != null) { + if (advapi32.RegCreateKeyEx(handle, name, 0, null, WinNT.REG_OPTION_NON_VOLATILE, WinNT.KEY_READ, null, + hkResult, dwDisposition) == WinError.ERROR_SUCCESS) { ret = true; advapi32.RegCloseKey(hkResult.getValue()); @@ -315,9 +353,10 @@ public class Registry { } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Delete a key. * @@ -326,17 +365,17 @@ public class Registry { * @param name key name * @return true on success */ - public static boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) { - Advapi32 advapi32; - int handle = 0; + static public boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) { + //Advapi32 advapi32; + //int handle = 0; boolean ret = false; - advapi32 = Advapi32.INSTANCE; - handle = openKey(rootKey, parent, WINNT.KEY_READ); + Advapi32 advapi32 = Advapi32.INSTANCE; + HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ); - if(handle != 0) { - - if(advapi32.RegDeleteKey(handle, name) == WINERROR.ERROR_SUCCESS) { + //if(handle != 0) { + if (handle != null) { + if (advapi32.RegDeleteKey(handle, name) == WinError.ERROR_SUCCESS) { ret = true; } else { @@ -344,9 +383,10 @@ public class Registry { } advapi32.RegCloseKey(handle); } - return(ret); + return ret; } + /** * Get all sub keys of a key. * @@ -354,35 +394,36 @@ public class Registry { * @param parent key name * @return array with all sub key names */ - public static String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) { - Advapi32 advapi32; - int handle = 0, dwIndex; + static public String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) { + //Advapi32 advapi32; + //int handle = 0, dwIndex; char[] lpName; IntByReference lpcName; - WINBASE.FILETIME lpftLastWriteTime; + WinBase.FILETIME lpftLastWriteTime; TreeSet subKeys = new TreeSet(); - advapi32 = Advapi32.INSTANCE; - handle = openKey(rootKey, parent, WINNT.KEY_READ); + Advapi32 advapi32 = Advapi32.INSTANCE; + HKEY handle = openKey(rootKey, parent, WinNT.KEY_READ); lpName = new char[256]; lpcName = new IntByReference(256); - lpftLastWriteTime = new WINBASE.FILETIME(); + lpftLastWriteTime = new WinBase.FILETIME(); - if(handle != 0) { - dwIndex = 0; + //if(handle != 0) { + if (handle != null) { + int dwIndex = 0; while(advapi32.RegEnumKeyEx(handle, dwIndex, lpName, lpcName, null, - null, null, lpftLastWriteTime) == WINERROR.ERROR_SUCCESS) { + null, null, lpftLastWriteTime) == WinError.ERROR_SUCCESS) { subKeys.add(new String(lpName, 0, lpcName.getValue())); lpcName.setValue(256); dwIndex++; } advapi32.RegCloseKey(handle); } - - return(subKeys.toArray(new String[]{})); + return subKeys.toArray(new String[] { }); } + /** * Get all values under a key. * @@ -391,45 +432,47 @@ public class Registry { * @throws java.io.UnsupportedEncodingException on error * @return TreeMap with name and value pairs */ - public static TreeMap getValues(REGISTRY_ROOT_KEY rootKey, String key) throws UnsupportedEncodingException { - Advapi32 advapi32; - int handle = 0, dwIndex, result = 0; + static public TreeMap getValues(REGISTRY_ROOT_KEY rootKey, String key) throws UnsupportedEncodingException { + //Advapi32 advapi32; + //int handle = 0, dwIndex, result = 0; char[] lpValueName; byte[] lpData; IntByReference lpcchValueName, lpType, lpcbData; String name; TreeMap values = new TreeMap(String.CASE_INSENSITIVE_ORDER); - advapi32 = Advapi32.INSTANCE; - handle = openKey(rootKey, key, WINNT.KEY_READ); + Advapi32 advapi32 = Advapi32.INSTANCE; + HKEY handle = openKey(rootKey, key, WinNT.KEY_READ); lpValueName = new char[16384]; lpcchValueName = new IntByReference(16384); lpType = new IntByReference(); lpData = new byte[1]; lpcbData = new IntByReference(); - if(handle != 0) { - dwIndex = 0; + //if(handle != 0) { + if (handle != null) { + int dwIndex = 0; + int result = 0; do { lpcbData.setValue(0); result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null, lpType, lpData, lpcbData); - if(result == WINERROR.ERROR_MORE_DATA) { + if (result == WinError.ERROR_MORE_DATA) { lpData = new byte[lpcbData.getValue()]; lpcchValueName = new IntByReference(16384); result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null, lpType, lpData, lpcbData); - if(result == WINERROR.ERROR_SUCCESS) { + if (result == WinError.ERROR_SUCCESS) { name = new String(lpValueName, 0, lpcchValueName.getValue()); switch(lpType.getValue()) { - case WINNT.REG_SZ: + case WinNT.REG_SZ: values.put(name, convertBufferToString(lpData)); break; - case WINNT.REG_DWORD: + case WinNT.REG_DWORD: values.put(name, convertBufferToInt(lpData)); break; default: @@ -438,10 +481,10 @@ public class Registry { } } dwIndex++; - } while(result == WINERROR.ERROR_SUCCESS); + } while (result == WinError.ERROR_SUCCESS); advapi32.RegCloseKey(handle); } - return(values); + return values; } } diff --git a/app/src/processing/app/windows/WINBASE.java b/app/src/processing/app/windows/WINBASE.java deleted file mode 100644 index c4807cc90..000000000 --- a/app/src/processing/app/windows/WINBASE.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * WINBASE.java - * - * Created on 5. September 2007, 11:24 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package processing.app.windows; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -/** - * - * @author TB - */ -public interface WINBASE { -/* -typedef struct _SECURITY_ATTRIBUTES { - DWORD nLength; - LPVOID lpSecurityDescriptor; - BOOL bInheritHandle; -} SECURITY_ATTRIBUTES, - *PSECURITY_ATTRIBUTES, - *LPSECURITY_ATTRIBUTES;*/ - public static class SECURITY_ATTRIBUTES extends Structure { - public int nLength; - public Pointer lpSecurityDescriptor; - public boolean bInheritHandle; - } - -/* -typedef struct _FILETIME { - DWORD dwLowDateTime; - DWORD dwHighDateTime; -} FILETIME, *PFILETIME, *LPFILETIME;*/ - public static class FILETIME extends Structure { - public int dwLowDateTime; - public int dwHighDateTime; - } -} diff --git a/app/src/processing/app/windows/WINERROR.java b/app/src/processing/app/windows/WINERROR.java deleted file mode 100644 index 3e1146e93..000000000 --- a/app/src/processing/app/windows/WINERROR.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * WINERROR.java - * - * Created on 7. August 2007, 08:09 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package processing.app.windows; - - -/** - * - * @author TB - */ -public interface WINERROR { - public final static int ERROR_SUCCESS = 0; - public final static int NO_ERROR = 0; - public final static int ERROR_FILE_NOT_FOUND = 2; - public final static int ERROR_MORE_DATA = 234; -} diff --git a/app/src/processing/app/windows/WINNT.java b/app/src/processing/app/windows/WINNT.java deleted file mode 100644 index 89aa36168..000000000 --- a/app/src/processing/app/windows/WINNT.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * WINNT.java - * - * Created on 8. August 2007, 13:41 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package processing.app.windows; - -/** - * - * @author TB - */ -public interface WINNT { - public final static int DELETE = 0x00010000; - public final static int READ_CONTROL = 0x00020000; - public final static int WRITE_DAC = 0x00040000; - public final static int WRITE_OWNER = 0x00080000; - public final static int SYNCHRONIZE = 0x00100000; - - public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000; - - public final static int STANDARD_RIGHTS_READ = READ_CONTROL; - public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL; - public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL; - - public final static int STANDARD_RIGHTS_ALL = 0x001F0000; - - public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF; - - public final static int GENERIC_EXECUTE = 0x20000000; - - public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010; - - public final static int KEY_QUERY_VALUE = 0x0001; - public final static int KEY_SET_VALUE = 0x0002; - public final static int KEY_CREATE_SUB_KEY = 0x0004; - public final static int KEY_ENUMERATE_SUB_KEYS = 0x0008; - public final static int KEY_NOTIFY = 0x0010; - public final static int KEY_CREATE_LINK = 0x0020; - - public final static int KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE)); - public final static int KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE)); - - public final static int REG_NONE = 0; // No value type - public final static int REG_SZ = 1; // Unicode nul terminated string - public final static int REG_EXPAND_SZ = 2; // Unicode nul terminated string - // (with environment variable references) - public final static int REG_BINARY = 3; // Free form binary - public final static int REG_DWORD = 4; // 32-bit number - public final static int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD) - public final static int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number - public final static int REG_LINK = 6; // Symbolic Link (unicode) - public final static int REG_MULTI_SZ = 7; // Multiple Unicode strings - public final static int REG_RESOURCE_LIST = 8; // Resource list in the resource map - public final static int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description - public final static int REG_RESOURCE_REQUIREMENTS_LIST = 10; - - public final static int REG_OPTION_RESERVED = 0x00000000; // Parameter is reserved - public final static int REG_OPTION_NON_VOLATILE = 0x00000000; // Key is preserved - // when system is rebooted - public final static int REG_OPTION_VOLATILE = 0x00000001; // Key is not preserved - // when system is rebooted - public final static int REG_OPTION_CREATE_LINK = 0x00000002; // Created key is a - // symbolic link - public final static int REG_OPTION_BACKUP_RESTORE = 0x00000004; // open for backup or restore - // special access rules - // privilege required - public final static int REG_OPTION_OPEN_LINK = 0x00000008; // Open symbolic link - -} diff --git a/app/src/processing/app/windows/WINREG.java b/app/src/processing/app/windows/WINREG.java deleted file mode 100644 index 988f7ef36..000000000 --- a/app/src/processing/app/windows/WINREG.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * WINREG.java - * - * Created on 17. August 2007, 14:32 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package processing.app.windows; - -/** - * - * @author TB - */ -public interface WINREG { - public final static int HKEY_CLASSES_ROOT = 0x80000000; - public final static int HKEY_CURRENT_USER = 0x80000001; - public final static int HKEY_LOCAL_MACHINE = 0x80000002; - public final static int HKEY_USERS = 0x80000003; -} diff --git a/core/todo.txt b/core/todo.txt index a0f15a529..59562aa52 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -11,11 +11,14 @@ X https://github.com/processing/processing/issues/1959 X turns out this is an apple.awt tweak for the exported Info.plist X getSubset() broken in IntList, StringList, and missing from FloatList X https://github.com/processing/processing/issues/1979 -X Present Mode trouble on Windows 7 (64-bit) completely broken +X Present Mode does not work properly on Windows X https://github.com/processing/processing/issues/1955 - +_ _ retain blendMode() between frames (get bug #) +_ this should actually be in the code.. +_ maybe not working on OS X/retina? +_ perhaps it's a getGraphics() issue? andres X pixels[] array not updated with Capture and P2D/P3D diff --git a/todo.txt b/todo.txt index 49d968ace..a66bec76c 100644 --- a/todo.txt +++ b/todo.txt @@ -24,25 +24,50 @@ manager X check to see if manager items from the download can be updated X oops, probably not, because they're part of the distribution X and folks won't be able to write to those directories -_ libraries need to support multiple categories -_ https://github.com/processing/processing/issues/1970 +X changed manager to go to download.processing.org/latest.txt +X and uses a redirect from there (hopeully that's followed?) +X libraries need to support multiple categories +X https://github.com/processing/processing/issues/1970 + +_ we shouldn't use .properties for modes et al +_ because a .properties file is iso8859-1 +_ remove "Compilations" category for libraries +_ make note that .properties file *must* be utf-8 +_ if not it'll make things gross (andre sier flob library) +_ restrict library categories to the ones in the document +_ if it's not correct, shows up as 'other' +_ argh.. the 'old' folder is really poorly done +_ attempt to install multiple will cause havoc (fail because 'old' exists) +_ modes and tools require restart (per ContributionType class) +_ but no message is provided anywhere? +_ why wasn't Library moved to LibraryContribution? _ send info on 'check for updates' so we know about libs/modes/etc? _ how to disclose to users? _ only send for items that are part of the public list _ otherwise we're sending private libraries/installs _ although this won't pick up old libraries not on the new system _ half-installed mode causes a lot of trouble +_ maybe it's reading from tmp folders? _ https://github.com/processing/processing/issues/1875 _ mode install requires restart *and* still doesn't show as installed _ even though it gets added to the modes menu properly after the restart _ https://github.com/processing/processing/issues/1782 _ classpath conflicts.. +_ getPackageList.. from Library... maybe others? _ really need to make sure that a weird core.jar isn't being imported _ coffeescript was doing this and breaking the pde _ init() not called on tools until later _ https://github.com/processing/processing/issues/1859 +_ contrib library examples are not read-only +_ another point for doing .zip files to prevent overwriting +_ add BookContribution? +_ will offer to open the contrib manager even though it's already open +_ though this was looking at libraries, and there may have been modes +_ update only showing up when selected is awkward +_ "update all" would be useful high +_ add .bat file to lib on windows so that we can get better debugging info _ move old Google Code SVN back to processing.org _ then cull out the old branches/tags from the Github repo _ UnsatisfiedLinkError causes huge message...