summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2007-04-16 15:24:09 +0000
committerSilenio Quarti <silenio>2007-04-16 15:24:09 +0000
commit4c435280edb60cfbc77445e11e94b7b62760dd4a (patch)
treef251df3e61f5da55bd51ab1d33981466ef1e9234
parent8b72b564b9ff2fcb6bceccc2bf17e820d59ce6f9 (diff)
downloadeclipse.platform.swt-4c435280edb60cfbc77445e11e94b7b62760dd4a.tar.gz
eclipse.platform.swt-4c435280edb60cfbc77445e11e94b7b62760dd4a.tar.xz
eclipse.platform.swt-4c435280edb60cfbc77445e11e94b7b62760dd4a.zip
96244 - [Program] Program.findProgram does not pick up customized applications for file extensions
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c82
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java64
8 files changed, 184 insertions, 14 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties
index 794d0332b2..8ff5be5541 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.win32.OS.properties
@@ -763,6 +763,22 @@ OS_Arc_6=
OS_Arc_7=
OS_Arc_8=
+OS_AssocQueryStringA=flags=dynamic
+OS_AssocQueryStringA_0=
+OS_AssocQueryStringA_1=
+OS_AssocQueryStringA_2=
+OS_AssocQueryStringA_3=
+OS_AssocQueryStringA_4=
+OS_AssocQueryStringA_5=
+
+OS_AssocQueryStringW=flags=dynamic
+OS_AssocQueryStringW_0=
+OS_AssocQueryStringW_1=
+OS_AssocQueryStringW_2=
+OS_AssocQueryStringW_3=
+OS_AssocQueryStringW_4=
+OS_AssocQueryStringW_5=
+
OS_AttachThreadInput=
OS_AttachThreadInput_0=cast=DWORD
OS_AttachThreadInput_1=cast=DWORD
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
index 921f6fbba5..21e7deff54 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
@@ -247,6 +247,88 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(Arc)
}
#endif
+#ifndef NO_AssocQueryStringA
+JNIEXPORT jint JNICALL OS_NATIVE(AssocQueryStringA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jintArray arg5)
+{
+ jbyte *lparg2=NULL;
+ jbyte *lparg3=NULL;
+ jbyte *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, AssocQueryStringA_FUNC);
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+/*
+ rc = (jint)AssocQueryStringA(arg0, arg1, lparg2, lparg3, lparg4, lparg5);
+*/
+ {
+ static int initialized = 0;
+ static HMODULE hm = NULL;
+ static FARPROC fp = NULL;
+ rc = 0;
+ if (!initialized) {
+ if (!hm) hm = LoadLibrary(AssocQueryStringA_LIB);
+ if (hm) fp = GetProcAddress(hm, "AssocQueryStringA");
+ initialized = 1;
+ }
+ if (fp) {
+ rc = (jint)fp(arg0, arg1, lparg2, lparg3, lparg4, lparg5);
+ }
+ }
+fail:
+ if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ OS_NATIVE_EXIT(env, that, AssocQueryStringA_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_AssocQueryStringW
+JNIEXPORT jint JNICALL OS_NATIVE(AssocQueryStringW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jcharArray arg3, jcharArray arg4, jintArray arg5)
+{
+ jchar *lparg2=NULL;
+ jchar *lparg3=NULL;
+ jchar *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, AssocQueryStringW_FUNC);
+ if (arg2) if ((lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+/*
+ rc = (jint)AssocQueryStringW(arg0, arg1, lparg2, lparg3, lparg4, lparg5);
+*/
+ {
+ static int initialized = 0;
+ static HMODULE hm = NULL;
+ static FARPROC fp = NULL;
+ rc = 0;
+ if (!initialized) {
+ if (!hm) hm = LoadLibrary(AssocQueryStringW_LIB);
+ if (hm) fp = GetProcAddress(hm, "AssocQueryStringW");
+ initialized = 1;
+ }
+ if (fp) {
+ rc = (jint)fp(arg0, arg1, lparg2, lparg3, lparg4, lparg5);
+ }
+ }
+fail:
+ if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ if (arg4 && lparg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
+ if (arg2 && lparg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ OS_NATIVE_EXIT(env, that, AssocQueryStringW_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_AttachThreadInput
JNIEXPORT jboolean JNICALL OS_NATIVE(AttachThreadInput)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
index df26b45f08..193987c2b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
@@ -133,8 +133,11 @@
#define NO_AbortDoc
#define NO_ActivateActCtx
#define NO_ActivateKeyboardLayout
+#define NO_AddFontResourceExA
#define NO_AddFontResourceExW
#define NO_Arc
+#define NO_AssocQueryStringA
+#define NO_AssocQueryStringW
#define NO_AttachThreadInput
#define NO_AlphaBlend
#define NO_AnimateWindow
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h
index 4d7dfd0339..a0e9828870 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.h
@@ -10,11 +10,13 @@
*******************************************************************************/
/* Libraries for dynamic loaded functions */
+#define ActivateActCtx_LIB "kernel32.dll"
#define AddFontResourceExA_LIB "gdi32.dll"
#define AddFontResourceExW_LIB "gdi32.dll"
-#define ActivateActCtx_LIB "kernel32.dll"
#define AlphaBlend_LIB "msimg32.dll"
#define AnimateWindow_LIB "user32.dll"
+#define AssocQueryStringA_LIB "shlwapi.dll"
+#define AssocQueryStringW_LIB "shlwapi.dll"
#define BufferedPaintInit_LIB "uxtheme.dll"
#define BufferedPaintUnInit_LIB "uxtheme.dll"
#define BufferedPaintSetAlpha_LIB "uxtheme.dll"
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
index b7aa6d331b..18e9f3892c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 865;
-int OS_nativeFunctionCallCount[865];
+int OS_nativeFunctionCount = 867;
+int OS_nativeFunctionCallCount[867];
char * OS_nativeFunctionNames[] = {
"ACCEL_1sizeof",
"ACTCTX_1sizeof",
@@ -28,6 +28,8 @@ char * OS_nativeFunctionNames[] = {
"AlphaBlend",
"AnimateWindow",
"Arc",
+ "AssocQueryStringA",
+ "AssocQueryStringW",
"AttachThreadInput",
"BITMAPINFOHEADER_1sizeof",
"BITMAP_1sizeof",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
index 9b8e36ac17..1a2254c7d6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
@@ -36,6 +36,8 @@ typedef enum {
AlphaBlend_FUNC,
AnimateWindow_FUNC,
Arc_FUNC,
+ AssocQueryStringA_FUNC,
+ AssocQueryStringW_FUNC,
AttachThreadInput_FUNC,
BITMAPINFOHEADER_1sizeof_FUNC,
BITMAP_1sizeof_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 05f91985b1..a44f1dca3a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -234,6 +234,11 @@ public class OS extends C {
// public static final int ACTCTX_FLAG_RESOURCE_NAME_VALID = 0x00000008;
// public static final int ACTCTX_FLAG_SET_PROCESS_DEFAULT = 0x00000010;
public static final int ALTERNATE = 1;
+ public static final int ASSOCF_NOTRUNCATE = 0x00000020;
+ public static final int ASSOCSTR_COMMAND = 1;
+ public static final int ASSOCSTR_DEFAULTICON = 15;
+ public static final int ASSOCSTR_FRIENDLYAPPNAME = 4;
+ public static final int ASSOCSTR_FRIENDLYDOCNAME = 3;
public static final int AW_SLIDE = 0x00040000;
public static final int AW_ACTIVATE = 0x00020000;
public static final int AW_BLEND = 0x00080000;
@@ -545,6 +550,7 @@ public class OS extends C {
public static final int DTS_SHORTDATEFORMAT = 0x0000;
public static final int DTS_TIMEFORMAT = 0x0009;
public static final int DTS_UPDOWN = 0x0001;
+ public static final int E_POINTER = 0x80004003;
public static final int EBP_NORMALGROUPBACKGROUND = 5;
public static final int EBP_NORMALGROUPCOLLAPSE = 6;
public static final int EBP_NORMALGROUPEXPAND = 7;
@@ -2146,6 +2152,19 @@ public static final int /*long*/ AddFontResourceEx (TCHAR lpszFilename, int fl,
return AddFontResourceExA (lpszFilename1, fl, pdv);
}
+public static final int /*long*/ AssocQueryString(int flags, int str, TCHAR pszAssoc, TCHAR pszExtra, TCHAR pszOut, int[] pcchOut) {
+ if (IsUnicode) {
+ char [] pszAssoc1 = pszAssoc == null ? null : pszAssoc.chars;
+ char [] pszExtra1 = pszExtra == null ? null : pszExtra.chars;
+ char [] pszOut1 = pszOut == null ? null : pszOut.chars;
+ return AssocQueryStringW (flags, str, pszAssoc1, pszExtra1, pszOut1, pcchOut);
+ }
+ byte [] pszAssoc1 = pszAssoc == null ? null : pszAssoc.bytes;
+ byte [] pszExtra1 = pszExtra == null ? null : pszExtra.bytes;
+ byte [] pszOut1 = pszOut == null ? null : pszOut.bytes;
+ return AssocQueryStringA (flags, str, pszAssoc1, pszExtra1, pszOut1, pcchOut);
+}
+
public static final int /*long*/ CallWindowProc (int /*long*/ lpPrevWndFunc, int /*long*/ hWnd, int Msg, int /*long*/ wParam, int /*long*/ lParam) {
if (IsUnicode) return CallWindowProcW (lpPrevWndFunc, hWnd, Msg, wParam, lParam);
return CallWindowProcA (lpPrevWndFunc, hWnd, Msg, wParam, lParam);
@@ -3104,6 +3123,8 @@ public static final native boolean AdjustWindowRectEx (RECT lpRect, int dwStyle,
public static final native boolean AlphaBlend(int /*long*/ hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int /*long*/ hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction);
public static final native boolean AnimateWindow(int /*long*/ hwnd, int dwTime, int dwFlags);
public static final native boolean Arc (int /*long*/ hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXStartArc, int nYStartArc, int nXEndArc, int nYEndArc);
+public static final native int AssocQueryStringA(int flags, int str, byte[] pszAssoc, byte[] pszExtra, byte[] pszOut, int[] pcchOut);
+public static final native int AssocQueryStringW(int flags, int str, char[] pszAssoc, char[] pszExtra, char[] pszOut, int[] pcchOut);
public static final native boolean AttachThreadInput (int idAttach, int idAttachTo, boolean fAttach);
public static final native int /*long*/ BeginBufferedPaint (int /*long*/ hdcTarget, RECT prcTarget, int dwFormat, BP_PAINTPARAMS pPaintParams, int /*long*/ [] phdc);
public static final native int /*long*/ BeginDeferWindowPos (int nNumWindows);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
index 234896fd78..621bebd7ba 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -31,6 +31,32 @@ public final class Program {
Program () {
}
+static String assocQueryString (int assocStr, TCHAR key, boolean expand) {
+ TCHAR pszOut = new TCHAR(0, 1024);
+ int[] pcchOut = new int[1];
+ pcchOut[0] = pszOut.length();
+ int result = OS.AssocQueryString(OS.ASSOCF_NOTRUNCATE, assocStr, key, null, pszOut, pcchOut);
+ if (result == OS.E_POINTER) {
+ pszOut = new TCHAR(0, pcchOut [0]);
+ result = OS.AssocQueryString(OS.ASSOCF_NOTRUNCATE, assocStr, key, null, pszOut, pcchOut);
+ }
+ if (result == 0) {
+ if (!OS.IsWinCE && expand) {
+ int length = OS.ExpandEnvironmentStrings (pszOut, null, 0);
+ if (length != 0) {
+ TCHAR lpDst = new TCHAR (0, length);
+ OS.ExpandEnvironmentStrings (pszOut, lpDst, length);
+ return lpDst.toString (0, Math.max (0, length - 1));
+ } else {
+ return "";
+ }
+ } else {
+ return pszOut.toString (0, Math.max (0, pcchOut [0] - 1));
+ }
+ }
+ return null;
+}
+
/**
* Finds the program that is associated with an extension.
* The extension may or may not begin with a '.'. Note that
@@ -50,19 +76,35 @@ public static Program findProgram (String extension) {
if (extension.charAt (0) != '.') extension = "." + extension; //$NON-NLS-1$
/* Use the character encoding for the default locale */
TCHAR key = new TCHAR (0, extension, true);
- int [] phkResult = new int [1];
- if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
- return null;
- }
Program program = null;
- int [] lpcbData = new int [1];
- int result = OS.RegQueryValueEx (phkResult [0], null, 0, null, (TCHAR) null, lpcbData);
- if (result == 0) {
- TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
- result = OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData);
- if (result == 0) program = getProgram (lpData.toString (0, lpData.strlen ()));
+ if (OS.IsWinCE) {
+ int [] phkResult = new int [1];
+ if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
+ return null;
+ }
+ int [] lpcbData = new int [1];
+ int result = OS.RegQueryValueEx (phkResult [0], null, 0, null, (TCHAR) null, lpcbData);
+ if (result == 0) {
+ TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
+ result = OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData);
+ if (result == 0) program = getProgram (lpData.toString (0, lpData.strlen ()));
+ }
+ OS.RegCloseKey (phkResult [0]);
+ } else {
+ String command = assocQueryString (OS.ASSOCSTR_COMMAND, key, true);
+ if (command != null) {
+ String name = null;
+ if (name == null) name = assocQueryString (OS.ASSOCSTR_FRIENDLYDOCNAME, key, false);
+ if (name == null) name = assocQueryString (OS.ASSOCSTR_FRIENDLYAPPNAME, key, false);
+ if (name == null) name = "";
+ String iconName = assocQueryString (OS.ASSOCSTR_DEFAULTICON, key, true);
+ if (iconName == null) iconName = "";
+ program = new Program ();
+ program.name = name;
+ program.command = command;
+ program.iconName = iconName;
+ }
}
- OS.RegCloseKey (phkResult [0]);
return program;
}