1 /*
2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * @(#)AccessBridgeCalls.c 1.25 05/08/22
28 */
29
30 /*
31 * Wrapper functions around calls to the AccessBridge DLL
32 */
33
34
35 #include <windows.h>
36 #include <jni.h>
37
38
39 //#define ACCESSBRIDGE_32
40 //#define ACCESSBRIDGE_64
41
42 #include "AccessBridgeCalls.h"
43 #include "AccessBridgeDebug.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 HINSTANCE theAccessBridgeInstance;
50 AccessBridgeFPs theAccessBridge;
51
52 BOOL theAccessBridgeInitializedFlag = FALSE;
53
54 #define LOAD_FP(result, type, name) \
55 PrintDebugString("LOAD_FP loading: %s ...", name); \
56 if ((theAccessBridge.result = \
57 (type) GetProcAddress(theAccessBridgeInstance, name)) == (type) 0) { \
58 PrintDebugString("LOAD_FP failed: %s", name); \
59 return FALSE; \
60 }
61
62 BOOL initializeAccessBridge() {
63
64 #ifdef ACCESSBRIDGE_ARCH_32 // For 32bit AT new bridge
65 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-32");
66 #else
67 #ifdef ACCESSBRIDGE_ARCH_64 // For 64bit AT new bridge
68 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-64");
69 #else // legacy
70 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE");
71 #endif
72 #endif
73 if (theAccessBridgeInstance != 0) {
74 LOAD_FP(Windows_run, Windows_runFP, "Windows_run");
75
76 LOAD_FP(SetJavaShutdown, SetJavaShutdownFP, "setJavaShutdownFP");
77 LOAD_FP(SetFocusGained, SetFocusGainedFP, "setFocusGainedFP");
78 LOAD_FP(SetFocusLost, SetFocusLostFP, "setFocusLostFP");
195 LOAD_FP(getTopLevelObject, getTopLevelObjectFP, "getTopLevelObject");
196 LOAD_FP(getParentWithRoleElseRoot, getParentWithRoleElseRootFP, "getParentWithRoleElseRoot");
197 LOAD_FP(getObjectDepth, getObjectDepthFP, "getObjectDepth");
198 LOAD_FP(getActiveDescendent, getActiveDescendentFP, "getActiveDescendent");
199
200 // additional methods for Teton
201 LOAD_FP(getVirtualAccessibleName, getVirtualAccessibleNameFP, "getVirtualAccessibleName");
202 LOAD_FP(requestFocus, requestFocusFP, "requestFocus");
203 LOAD_FP(selectTextRange, selectTextRangeFP, "selectTextRange");
204 LOAD_FP(getTextAttributesInRange, getTextAttributesInRangeFP, "getTextAttributesInRange");
205 LOAD_FP(getVisibleChildrenCount, getVisibleChildrenCountFP, "getVisibleChildrenCount");
206 LOAD_FP(getVisibleChildren, getVisibleChildrenFP, "getVisibleChildren");
207 LOAD_FP(setCaretPosition, setCaretPositionFP, "setCaretPosition");
208 LOAD_FP(getCaretLocation, getCaretLocationFP, "getCaretLocation");
209
210 LOAD_FP(getEventsWaiting, getEventsWaitingFP, "getEventsWaiting");
211
212 theAccessBridge.Windows_run();
213
214 theAccessBridgeInitializedFlag = TRUE;
215 PrintDebugString("theAccessBridgeInitializedFlag = TRUE");
216 return TRUE;
217 } else {
218 return FALSE;
219 }
220 }
221
222
223 BOOL shutdownAccessBridge() {
224 BOOL result;
225 DWORD error;
226 theAccessBridgeInitializedFlag = FALSE;
227 if (theAccessBridgeInstance != (HANDLE) 0) {
228 result = FreeLibrary(theAccessBridgeInstance);
229 if (result != TRUE) {
230 error = GetLastError();
231 }
232 return TRUE;
233 }
234 return FALSE;
235 }
|
1 /*
2 *
3 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Oracle nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /*
34 * @(#)AccessBridgeCalls.c 1.25 05/08/22
35 */
36
37 /*
38 * Wrapper functions around calls to the AccessBridge DLL
39 */
40
41
42 #include <windows.h>
43 #include <jni.h>
44
45
46 //#define ACCESSBRIDGE_32
47 //#define ACCESSBRIDGE_64
48
49 #include "AccessBridgeCalls.h"
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 HINSTANCE theAccessBridgeInstance;
56 AccessBridgeFPs theAccessBridge;
57
58 BOOL theAccessBridgeInitializedFlag = FALSE;
59
60 #define LOAD_FP(result, type, name) \
61 if ((theAccessBridge.result = \
62 (type) GetProcAddress(theAccessBridgeInstance, name)) == (type) 0) { \
63 return FALSE; \
64 }
65
66 BOOL initializeAccessBridge() {
67
68 #ifdef ACCESSBRIDGE_ARCH_32 // For 32bit AT new bridge
69 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-32");
70 #else
71 #ifdef ACCESSBRIDGE_ARCH_64 // For 64bit AT new bridge
72 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-64");
73 #else // legacy
74 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE");
75 #endif
76 #endif
77 if (theAccessBridgeInstance != 0) {
78 LOAD_FP(Windows_run, Windows_runFP, "Windows_run");
79
80 LOAD_FP(SetJavaShutdown, SetJavaShutdownFP, "setJavaShutdownFP");
81 LOAD_FP(SetFocusGained, SetFocusGainedFP, "setFocusGainedFP");
82 LOAD_FP(SetFocusLost, SetFocusLostFP, "setFocusLostFP");
199 LOAD_FP(getTopLevelObject, getTopLevelObjectFP, "getTopLevelObject");
200 LOAD_FP(getParentWithRoleElseRoot, getParentWithRoleElseRootFP, "getParentWithRoleElseRoot");
201 LOAD_FP(getObjectDepth, getObjectDepthFP, "getObjectDepth");
202 LOAD_FP(getActiveDescendent, getActiveDescendentFP, "getActiveDescendent");
203
204 // additional methods for Teton
205 LOAD_FP(getVirtualAccessibleName, getVirtualAccessibleNameFP, "getVirtualAccessibleName");
206 LOAD_FP(requestFocus, requestFocusFP, "requestFocus");
207 LOAD_FP(selectTextRange, selectTextRangeFP, "selectTextRange");
208 LOAD_FP(getTextAttributesInRange, getTextAttributesInRangeFP, "getTextAttributesInRange");
209 LOAD_FP(getVisibleChildrenCount, getVisibleChildrenCountFP, "getVisibleChildrenCount");
210 LOAD_FP(getVisibleChildren, getVisibleChildrenFP, "getVisibleChildren");
211 LOAD_FP(setCaretPosition, setCaretPositionFP, "setCaretPosition");
212 LOAD_FP(getCaretLocation, getCaretLocationFP, "getCaretLocation");
213
214 LOAD_FP(getEventsWaiting, getEventsWaitingFP, "getEventsWaiting");
215
216 theAccessBridge.Windows_run();
217
218 theAccessBridgeInitializedFlag = TRUE;
219 return TRUE;
220 } else {
221 return FALSE;
222 }
223 }
224
225
226 BOOL shutdownAccessBridge() {
227 BOOL result;
228 DWORD error;
229 theAccessBridgeInitializedFlag = FALSE;
230 if (theAccessBridgeInstance != (HANDLE) 0) {
231 result = FreeLibrary(theAccessBridgeInstance);
232 if (result != TRUE) {
233 error = GetLastError();
234 }
235 return TRUE;
236 }
237 return FALSE;
238 }
|