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 #include <windows.h> // includes basic windows functionality 27 #include <stdio.h> 28 #include <commctrl.h> 29 #include <jni.h> 30 #include "jaccesswalkerResource.h" 31 #include "AccessBridgeCalls.h" 32 #include "AccessBridgeCallbacks.h" 33 #include "AccessBridgeDebug.h" 34 35 #include <windows.h> 36 #include <stdio.h> 37 #include <stdlib.h> 38 #include <io.h> 39 #include <direct.h> 40 #include <process.h> 41 42 #include <time.h> 43 44 extern FILE *file; 45 46 #define null NULL 47 #define JACCESSWALKER_LOG "jaccesswalker.log" 48 49 /** 50 * A node in the jaccesswalker tree 51 */ 52 class AccessibleNode { 53 54 HWND baseHWND; 55 HTREEITEM treeNodeParent; 56 long vmID; 57 AccessibleContext ac; 58 AccessibleNode *parentNode; 59 char accessibleName[MAX_STRING_SIZE]; 60 char accessibleRole[SHORT_STRING_SIZE]; 61 62 public: 63 AccessibleNode(long vmID, AccessibleContext context, 64 AccessibleNode *parent, HWND hWnd, 65 HTREEITEM parentTreeNodeItem); 66 ~AccessibleNode(); 67 void setAccessibleName(char *name); 68 void setAccessibleRole(char *role); 69 BOOL displayAPIWindow(); // bring up an Accessibility API detail window 70 }; 71 72 73 /** 74 * The main application class 75 */ 76 class Jaccesswalker { 77 78 public: 79 Jaccesswalker(int nCmdShow); 80 BOOL InitWindow(int windowMode); 81 char *getAccessibleInfo( long vmID, AccessibleContext ac, char *buffer, 82 int bufsize ); 83 void exitjaccesswalker(HWND hWnd); 84 void buildAccessibilityTree(); 85 void addComponentNodes( long vmID, AccessibleContext context, 86 AccessibleNode *parent, HWND hWnd, 87 HTREEITEM treeNodeParent, HWND treeWnd ); 88 }; 89 90 char *getTimeAndDate(); 91 92 void displayAndLogText(char *buffer, ...); 93 94 LRESULT CALLBACK WinProc (HWND, UINT, WPARAM, LPARAM); 95 96 void debugString(char *msg, ...); 97 98 LRESULT CALLBACK jaccesswalkerWindowProc( HWND hDlg, UINT message, UINT wParam, 99 LONG lParam ); 100 101 BOOL CALLBACK EnumWndProc(HWND hWnd, LPARAM lParam); 102 BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam); 103 104 HWND CreateATreeView(HWND hwndParent); 105 106 LRESULT CALLBACK AccessInfoWindowProc( HWND hWnd, UINT message, UINT wParam, 107 LONG lParam ); 108 109 char *getAccessibleInfo( long vmID, AccessibleContext ac, char *buffer, 110 int bufsize ); 111