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");
79
80 LOAD_FP(SetCaretUpdate, SetCaretUpdateFP, "setCaretUpdateFP");
81
82 LOAD_FP(SetMouseClicked, SetMouseClickedFP, "setMouseClickedFP");
83 LOAD_FP(SetMouseEntered, SetMouseEnteredFP, "setMouseEnteredFP");
84 LOAD_FP(SetMouseExited, SetMouseExitedFP, "setMouseExitedFP");
85 LOAD_FP(SetMousePressed, SetMousePressedFP, "setMousePressedFP");
86 LOAD_FP(SetMouseReleased, SetMouseReleasedFP, "setMouseReleasedFP");
87
88 LOAD_FP(SetMenuCanceled, SetMenuCanceledFP, "setMenuCanceledFP");
89 LOAD_FP(SetMenuDeselected, SetMenuDeselectedFP, "setMenuDeselectedFP");
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 * Wrapper functions around calls to the AccessBridge DLL
35 */
36
37
38 #include <windows.h>
39 #include <jni.h>
40
41
42 //#define ACCESSBRIDGE_32
43 //#define ACCESSBRIDGE_64
44
45 #include "AccessBridgeCalls.h"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 HINSTANCE theAccessBridgeInstance;
52 AccessBridgeFPs theAccessBridge;
53
54 BOOL theAccessBridgeInitializedFlag = FALSE;
55
56 #define LOAD_FP(result, type, name) \
57 if ((theAccessBridge.result = \
58 (type) GetProcAddress(theAccessBridgeInstance, name)) == (type) 0) { \
59 return FALSE; \
60 }
61
62 BOOL initializeAccessBridge() {
63
64 #ifdef ACCESSBRIDGE_ARCH_32 // For 32 bit AT interfacing with Java on 64 bit OS
65 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-32");
66 #else
67 #ifdef ACCESSBRIDGE_ARCH_64 // For 64 bit AT interfacing with Java on 64 bit OS
68 theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-64");
69 #else // For 32 bit AT interfacing with Java on 32 bit OS
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");
79
80 LOAD_FP(SetCaretUpdate, SetCaretUpdateFP, "setCaretUpdateFP");
81
82 LOAD_FP(SetMouseClicked, SetMouseClickedFP, "setMouseClickedFP");
83 LOAD_FP(SetMouseEntered, SetMouseEnteredFP, "setMouseEnteredFP");
84 LOAD_FP(SetMouseExited, SetMouseExitedFP, "setMouseExitedFP");
85 LOAD_FP(SetMousePressed, SetMousePressedFP, "setMousePressedFP");
86 LOAD_FP(SetMouseReleased, SetMouseReleasedFP, "setMouseReleasedFP");
87
88 LOAD_FP(SetMenuCanceled, SetMenuCanceledFP, "setMenuCanceledFP");
89 LOAD_FP(SetMenuDeselected, SetMenuDeselectedFP, "setMenuDeselectedFP");
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 return TRUE;
216 } else {
217 return FALSE;
218 }
219 }
220
221
222 BOOL shutdownAccessBridge() {
223 BOOL result;
224 DWORD error;
225 theAccessBridgeInitializedFlag = FALSE;
226 if (theAccessBridgeInstance != (HANDLE) 0) {
227 result = FreeLibrary(theAccessBridgeInstance);
228 if (result != TRUE) {
229 error = GetLastError();
230 }
231 return TRUE;
232 }
233 return FALSE;
234 }
|