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  * A DLL which is loaded by Java applications to handle communication
  28  * between Java VMs purposes of Accessbility.
  29  */
  30 
  31 #include "AccessBridgeDebug.h"
  32 #include "JavaAccessBridge.h"
  33 #include "com_sun_java_accessibility_AccessBridge.h" // programatically generated by JNI
  34 #include "accessBridgeResource.h"
  35 #include "accessBridgeCallbacks.h"
  36 #include "AccessBridgeMessages.h"
  37 
  38 
  39 #include <windows.h>
  40 #include <stdio.h>
  41 
  42 // #ifdef JAWT_SUPPORT
  43 #include <jawt.h>
  44 #include <win32/jawt_md.h>
  45 // #endif /* JAWT_SUPPORT */
  46 
  47 JavaAccessBridge *theJavaAccessBridge;
  48 HWND theDialogWindow;
  49 
  50 // re-entrance lock for receiving memory messages
  51 CRITICAL_SECTION receiveMemoryIPCLock;
  52 
  53 
  54 // unique broadcast msg. IDs gotten dymanically
  55 extern UINT theFromJavaHelloMsgID;
  56 extern UINT theFromWindowsHelloMsgID;
  57 
  58 
  59 // ---------------------------------------------------------------------------
  60 
  61 extern "C" {
  62     /**
  63      * DllMain - where Windows executables will load/unload us
  64      *
  65      */
  66     BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) {
  67 
  68         switch (fdwReason) {
  69         case DLL_PROCESS_ATTACH:
  70             InitializeCriticalSection(&receiveMemoryIPCLock);
  71             theJavaAccessBridge = new JavaAccessBridge(hinstDll);
  72             break;
  73 
  74         case DLL_PROCESS_DETACH:        // A Windows executable unloaded us
  75             if (theJavaAccessBridge != (JavaAccessBridge *) 0) {
  76                 delete theJavaAccessBridge;
  77                 DeleteCriticalSection(&receiveMemoryIPCLock);
  78             }
  79             break;
  80         }
  81         return TRUE;
  82     }
  83 
  84     /**
  85      * Open a native window (and init the wrappers we'll be using)
  86      *
  87      */
  88     JNIEXPORT void JNICALL
  89     Java_com_sun_java_accessibility_AccessBridge_runDLL(JNIEnv *env, jobject obj) {
  90         PrintDebugString("\r\nJavaAccessBridge.DLL runDLL() called");
  91         theJavaAccessBridge->javaRun(env, obj);
  92     }
  93 
  94 #if 0 // SetDlgItemText has caused problems with JAWS
  95     /**
  96      * Append debug info to dialog
  97      *
  98      */
  99     void AppendToCallInfo(char *s) {
 100         char buffer[4096];
 101 
 102         PrintDebugString(s);
 103 
 104         GetDlgItemText(theDialogWindow, cCallInfo, buffer, sizeof(buffer));
 105         if (strlen(buffer) < (sizeof(buffer) - strlen(s))) {
 106             strncat(buffer, s, sizeof(buffer));
 107             SetDlgItemText(theDialogWindow, cCallInfo, buffer);
 108         } else {
 109             SetDlgItemText(theDialogWindow, cCallInfo, s);
 110         }
 111     }
 112 #endif
 113 
 114 
 115     /**
 116      * Our window proc
 117      *
 118      */
 119     BOOL APIENTRY AccessBridgeDialogProc (HWND hDlg, UINT message, UINT wParam, LONG lParam) {
 120         int command;
 121         COPYDATASTRUCT *sentToUs;
 122         char *package;
 123         //DEBUG_CODE(char buffer[256]);
 124 
 125         switch (message) {
 126         case WM_INITDIALOG:
 127             //DEBUG_CODE(SetDlgItemText(theDialogWindow, cStatusText, "Initializing"));
 128             break;
 129 
 130         case WM_COMMAND:
 131             command = LOWORD (wParam);
 132             break;
 133 
 134             // call from Java with data for us to deliver
 135         case WM_COPYDATA:
 136             if (theDialogWindow == (HWND) wParam) {
 137                 //DEBUG_CODE(SetDlgItemText(theDialogWindow, cStatusText, "Got WM_COPYDATA from ourselves"));
 138             } else {
 139                 //DEBUG_CODE(sprintf(buffer, "Got WM_COPYDATA from HWND %p", wParam));
 140                 //DEBUG_CODE(SetDlgItemText(theDialogWindow, cStatusText, buffer));
 141                 sentToUs = (COPYDATASTRUCT *) lParam;
 142                 package = (char *) sentToUs->lpData;
 143                 theJavaAccessBridge->processPackage(package, sentToUs->cbData);
 144             }
 145             break;
 146 
 147             // call from Java with data for us retrieve from memory mapped file and deliver
 148         case AB_MESSAGE_WAITING:
 149             // wParam == sourceHwnd
 150             // lParam == buffer size in shared memory
 151             if (theDialogWindow == (HWND) wParam) {
 152                 //DEBUG_CODE(SetDlgItemText(theDialogWindow, cStatusText, "Got AB_MESSAGE_WAITING from ourselves"));
 153             } else {
 154                 //DEBUG_CODE(sprintf(buffer, "Got AB_MESSAGE_WAITING from HWND %p", wParam));
 155                 //DEBUG_CODE(SetDlgItemText(theDialogWindow, cStatusText, buffer));
 156                 LRESULT returnVal = theJavaAccessBridge->receiveMemoryPackage((HWND) wParam, lParam);
 157             }
 158             break;
 159 
 160             // a JavaAccessBridge DLL is going away
 161         case AB_DLL_GOING_AWAY:
 162             // wParam == sourceHwnd
 163             //DEBUG_CODE(SetDlgItemText(theDialogWindow, cStatusText, "Got AB_DLL_GOING_AWAY message"));
 164             theJavaAccessBridge->WindowsATDestroyed((HWND) wParam);
 165             break;
 166 
 167         default:
 168             // the Windows AT is saying "hi"!
 169             // wParam == sourceHwnc; lParam unused
 170             if (message == theFromWindowsHelloMsgID) {
 171                 // A new Windows AT just said "hi";
 172                 // say "hi" back so it can mate up with us
 173                 // otherwise don't do anything (e.g. don't set up data structures yet)
 174                 theJavaAccessBridge->postHelloToWindowsDLLMsg((HWND) wParam);
 175             }
 176         }
 177         return FALSE;
 178     }
 179 
 180 }
 181 
 182 
 183 // -----------------------------
 184 
 185 
 186 /**
 187  * Initialize the JavaAccessBridge
 188  *
 189  */
 190 JavaAccessBridge::JavaAccessBridge(HINSTANCE hInstance) {
 191     windowsInstance = hInstance;
 192     ATs = (AccessBridgeATInstance *) 0;
 193     initBroadcastMessageIDs();          // get the unique to us broadcast msg. IDs
 194 }
 195 
 196 extern DWORD JavaBridgeThreadId;
 197 
 198 /**
 199  * Destroy the JavaAccessBridge
 200  *
 201  */
 202 JavaAccessBridge::~JavaAccessBridge() {
 203     // inform all other AccessBridges that we're going away
 204 
 205     PrintDebugString("\r\nin JavaAccessBridge::~JavaAccessBridge()");
 206 
 207     // Send a shutdown message for those applications like StarOffice that do
 208     // send a shutdown message themselves.
 209     javaShutdown(NULL, 0);
 210 
 211     AccessBridgeATInstance *current = ATs;
 212     while (current != (AccessBridgeATInstance *) 0) {
 213         PrintDebugString("  telling %p we're going away", current->winAccessBridgeWindow);
 214                 SendMessage(current->winAccessBridgeWindow,
 215                     AB_DLL_GOING_AWAY, (WPARAM) dialogWindow, (LPARAM) 0);
 216         current = current->nextATInstance;
 217     }
 218 
 219     PrintDebugString("  finished telling ATs about our demise");
 220 
 221         if(JavaBridgeThreadId)
 222                 {
 223                 PostThreadMessage(JavaBridgeThreadId,WM_USER+1,0,0);
 224                 Sleep(100);
 225                 }
 226 
 227     delete ATs;
 228 
 229     PrintDebugString("  finished deleting ATs");
 230     PrintDebugString("GOODBYE CRUEL WORLD...");
 231 }
 232 
 233 
 234 void
 235 JavaAccessBridge::javaRun(JNIEnv *env, jobject obj) {
 236     MSG msg;
 237 
 238     PrintDebugString("JavaAccessBridge::javaRun(%p, %p) called", env, obj);
 239 
 240     if (env->GetJavaVM(&javaVM) != 0) {
 241         return; // huh!?!?!
 242     }
 243     PrintDebugString("  -> javaVM = %p", javaVM);
 244 
 245     if (javaVM->AttachCurrentThread((void **) &windowsThreadJNIEnv, NULL) != 0) {
 246         return; // huh!?!?!
 247     }
 248     PrintDebugString("  -> windowsThreadJNIEnv = %p", windowsThreadJNIEnv);
 249 
 250     javaThreadABObject = env->NewGlobalRef(obj);
 251     windowsThreadABObject = windowsThreadJNIEnv->NewGlobalRef(obj);
 252 
 253     // initialize the Java thread AccessBridge entry points
 254     javaThreadEntryPoints = new AccessBridgeJavaEntryPoints(env, javaThreadABObject);
 255     if (javaThreadEntryPoints->BuildJavaEntryPoints() == FALSE) {
 256         return;         // couldn't build our entry points; let's get out of here!
 257     }
 258     PrintDebugString("  all Java thread entry points successfully found.");
 259 
 260     // initialize the Windows thread AccessBridge entry points
 261     windowsThreadEntryPoints = new AccessBridgeJavaEntryPoints(windowsThreadJNIEnv,
 262                                                                windowsThreadABObject);
 263     if (windowsThreadEntryPoints->BuildJavaEntryPoints() == FALSE) {
 264         return;         // couldn't build our entry points; let's get out of here!
 265     }
 266     PrintDebugString("  all Windows thread entry points successfully found.");
 267 
 268 
 269     // open our window
 270     if (initWindow() == TRUE) {
 271         PrintDebugString("  Window created.  HWND = %p", dialogWindow);
 272 
 273         // post a broadcast msg.; let other AccessBridge DLLs know we exist
 274         postHelloToWindowsDLLMsg(HWND_BROADCAST);
 275 
 276         // do that message loop thing
 277         while (GetMessage(&msg, NULL, 0, 0)) {
 278             TranslateMessage(&msg);
 279             DispatchMessage(&msg);
 280         }
 281     } else {
 282         PrintDebugString("  FAILED TO CREATE WINDOW!!!");
 283     }
 284 
 285     javaVM->DetachCurrentThread();
 286 }
 287 
 288 /**
 289  * Bring up our window; make a connection to the rest of the world
 290  *
 291  */
 292 BOOL
 293 JavaAccessBridge::initWindow() {
 294     theDialogWindow = CreateDialog(windowsInstance,
 295                                    "ACCESSBRIDGESTATUSWINDOW", NULL,
 296                                    (DLGPROC) AccessBridgeDialogProc);
 297 
 298     // If window could not be created, return "failure".
 299     if (!theDialogWindow)
 300         return FALSE;
 301 
 302     dialogWindow = theDialogWindow;
 303 
 304     // Make the window visible, update its client area, & return "success".
 305     // DEBUG_CODE(ShowWindow (theDialogWindow, SW_SHOWNORMAL));
 306     // DEBUG_CODE(UpdateWindow (theDialogWindow));
 307 
 308     return TRUE;
 309 }
 310 
 311 
 312 
 313 // -----------------------
 314 
 315 
 316 /**
 317  * postHelloToWindowsDLLMsg
 318  *          - PostMessage(theFromJavaHelloMsgID) to let one or
 319  *            all WindowDLLs we're here and have a vmID
 320  *
 321  *            destHwnd is either a single hwnd or HWND_BROADCAST
 322  *              (former if a reply, latter if we're just born)
 323  *            wParam is our HWND
 324  *            lParam is our vmID
 325  *
 326  */
 327 void
 328 JavaAccessBridge::postHelloToWindowsDLLMsg(HWND destHwnd) {
 329     PrintDebugString("\r\nin JavaAccessBridge::postHelloToWindowsDLLMsg");
 330     PrintDebugString("  calling PostMessage(%p, %X, %p, %p)",
 331                      destHwnd, theFromJavaHelloMsgID, dialogWindow, javaVM);
 332     PostMessage(destHwnd, theFromJavaHelloMsgID, (WPARAM) dialogWindow, (LPARAM) dialogWindow);
 333 }
 334 
 335 
 336 // -----------------------
 337 
 338 /**
 339  * sendPackage - uses SendMessage(WM_COPYDATA) to do IPC messaging
 340  *                                with the Java AccessBridge DLL
 341  *
 342  */
 343 void
 344 JavaAccessBridge::sendPackage(char *buffer, int bufsize, HWND destHwnd) {
 345     COPYDATASTRUCT toCopy;
 346     toCopy.dwData = 0;          // 32-bits we could use for something...
 347     toCopy.cbData = bufsize;
 348     toCopy.lpData = buffer;
 349 
 350     SendMessage(destHwnd, WM_COPYDATA, (WPARAM) dialogWindow, (LPARAM) &toCopy);
 351 }
 352 
 353 
 354 /**
 355  * sendJavaEventPackage - walk through ATs, sending event messages to 'em
 356  *
 357  */
 358 void
 359 JavaAccessBridge::sendJavaEventPackage(char *buffer, int bufsize, long type) {
 360 
 361     PrintDebugString("JavaAccessBridge::sendJavaEventPackage(), type = %X", type);
 362 
 363     if (ATs == (AccessBridgeATInstance *) 0) {
 364         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
 365     }
 366 
 367     AccessBridgeATInstance *ati = ATs;
 368     while (ati != (AccessBridgeATInstance *) 0) {
 369         ati->sendJavaEventPackage(buffer, bufsize, type);
 370         ati = ati->nextATInstance;
 371     }
 372 }
 373 
 374 /**
 375  * sendAccessibilityEventPackage - walk through ATs, sending event messages to 'em
 376  *
 377  */
 378 void
 379 JavaAccessBridge::sendAccessibilityEventPackage(char *buffer, int bufsize, long type) {
 380 
 381     PrintDebugString("JavaAccessBridge::sendAccessibilityEventPackage(), type = %X", type);
 382 
 383     if (ATs == (AccessBridgeATInstance *) 0) {
 384         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
 385     }
 386 
 387     AccessBridgeATInstance *ati = ATs;
 388     while (ati != (AccessBridgeATInstance *) 0) {
 389         ati->sendAccessibilityEventPackage(buffer, bufsize, type);
 390         ati = ati->nextATInstance;
 391     }
 392 }
 393 
 394 
 395 
 396 
 397 /**
 398  * receiveMemoryPackage - uses Memory-Mapped files to do IPC messaging
 399  *                        with the Java AccessBridge DLL, receiving the
 400  *                        message from Java AccessBridge DLL by reading the
 401  *                        contents of the shared memory mapped file that
 402  *                        is used for Java-initiated messages
 403  *
 404  */
 405 BOOL
 406 JavaAccessBridge::receiveMemoryPackage(HWND srcWindow, long bufsize) {
 407     char *IPCview;
 408 
 409     PrintDebugString("\r\nJavaAccessBridge::receiveMemoryPackage(%p, %d)", srcWindow, bufsize);
 410 
 411     // look-up the appropriate IPCview based on the srcHWND of the Windows AccessBridge DLL
 412     if (ATs == (AccessBridgeATInstance *) 0) {
 413         PrintDebugString("  ERROR! - ATs == 0 (shouldn't happen in receiveMemoryPackage()!");
 414         return FALSE;
 415     }
 416     AccessBridgeATInstance *ati = ATs->findABATInstanceFromATHWND(srcWindow);
 417     if (ati != (AccessBridgeATInstance *) 0) {
 418         IPCview = (char *) ati->memoryMappedView;
 419 
 420         // wait for the lock if someone else has it (re-entrancy)
 421         EnterCriticalSection(&receiveMemoryIPCLock);
 422         {
 423             // set byte at end of buffer to indicate to caller that we have reached this point
 424             IPCview[bufsize] = 1;
 425 
 426             // process the package
 427             processPackage(IPCview, bufsize);
 428         }
 429         // release re-entrance lock
 430         LeaveCriticalSection(&receiveMemoryIPCLock);
 431 
 432         return TRUE;
 433 
 434     } else {
 435         //DEBUG_CODE(AppendToCallInfo("ERROR receiving memory package: couldn't find srcWindow"));
 436         PrintDebugString("ERROR receiving memory package: couldn't find srcWindow");
 437         return FALSE;
 438     }
 439 }
 440 
 441 /**
 442  * processPackage - processes the output of SendMessage(WM_COPYDATA)
 443  *                                      to do IPC messaging with the Windows AccessBridge DLL
 444  *
 445  */
 446 LRESULT
 447 JavaAccessBridge::processPackage(char *buffer, int bufsize) {
 448     PrintDebugString("\r\nProcessing package sent from Windows, bufsize = %d:", bufsize);
 449 
 450     PackageType *type = (PackageType *) buffer;
 451     LRESULT returnVal = 0;
 452     PrintDebugString("  PackageType = %X:", *type);
 453     jobject rAC;
 454 
 455     switch (*type) {
 456 
 457 
 458     case cMemoryMappedFileCreatedPackage:
 459         // Windows is telling us it created a memory mapped file for us to use
 460         // in repsonding to various information querying packages (see below)
 461         PrintDebugString("   type == cMemoryMappedFileCreatedPackage");
 462         if (bufsize == (sizeof(PackageType) + sizeof(MemoryMappedFileCreatedPackage))) {
 463             MemoryMappedFileCreatedPackage *pkg =
 464                 (MemoryMappedFileCreatedPackage *) (buffer + sizeof(PackageType));
 465             returnVal = MemoryMappedFileCreated((HWND)ABLongToHandle(pkg->bridgeWindow), pkg->filename);
 466         } else {
 467             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 468                              bufsize, sizeof(PackageType) + sizeof(MemoryMappedFileCreatedPackage));
 469         }
 470         break;
 471 
 472         // ------------ information querying packages ------------------
 473 
 474     case cReleaseJavaObjectPackage:
 475         PrintDebugString("   type == cReleaseJavaObjectPackage");
 476         if (bufsize == (sizeof(PackageType) + sizeof(ReleaseJavaObjectPackage))) {
 477             ReleaseJavaObjectPackage *pkg =
 478                 (ReleaseJavaObjectPackage *) (buffer + sizeof(PackageType));
 479             releaseJavaObject((jobject)pkg->object);
 480         } else {
 481             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 482                              bufsize, sizeof(PackageType) + sizeof(ReleaseJavaObjectPackage));
 483         }
 484         break;
 485 
 486     case cGetAccessBridgeVersionPackage:
 487         PrintDebugString("   type == cGetAccessBridgeVersionPackage");
 488         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessBridgeVersionPackage))) {
 489             GetAccessBridgeVersionPackage *pkg =
 490                 (GetAccessBridgeVersionPackage *) (buffer + sizeof(PackageType));
 491             windowsThreadEntryPoints->getVersionInfo(&(pkg->rVersionInfo));
 492         } else {
 493             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 494                              bufsize, sizeof(PackageType) + sizeof(GetAccessBridgeVersionPackage));
 495         }
 496         break;
 497 
 498     case cIsJavaWindowPackage:
 499         PrintDebugString("   type == cIsJavaWindowPackage");
 500         if (bufsize == (sizeof(PackageType) + sizeof(IsJavaWindowPackage))) {
 501             IsJavaWindowPackage *pkg =
 502                 (IsJavaWindowPackage *) (buffer + sizeof(PackageType));
 503             pkg->rResult =
 504                 windowsThreadEntryPoints->isJavaWindow(pkg->window);
 505             PrintDebugString("     -> returning result = %d", pkg->rResult);
 506         } else {
 507             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 508                              bufsize, sizeof(PackageType) + sizeof(IsJavaWindowPackage));
 509         }
 510         break;
 511 
 512     case cIsSameObjectPackage:
 513         PrintDebugString("   type == cIsSameObjectPackage");
 514         if (bufsize == (sizeof(PackageType) + sizeof(IsSameObjectPackage))) {
 515             IsSameObjectPackage *pkg =
 516                 (IsSameObjectPackage *) (buffer + sizeof(PackageType));
 517             pkg->rResult =
 518                 windowsThreadEntryPoints->isSameObject((jobject)pkg->obj1, (jobject)pkg->obj2);
 519             PrintDebugString("     -> returning result = %d", pkg->rResult);
 520         } else {
 521             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 522                              bufsize, sizeof(PackageType) + sizeof(IsSameObjectPackage));
 523         }
 524         break;
 525 
 526 
 527     case cGetAccessibleContextFromHWNDPackage:
 528         PrintDebugString("   type == cGetAccessibleContextFromHWNDPackage");
 529         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage))) {
 530             GetAccessibleContextFromHWNDPackage *pkg =
 531                 (GetAccessibleContextFromHWNDPackage *) (buffer + sizeof(PackageType));
 532             rAC = windowsThreadEntryPoints->getAccessibleContextFromHWND(pkg->window);
 533             pkg->rAccessibleContext = (JOBJECT64)rAC;
 534             pkg->rVMID = HandleToLong(dialogWindow);
 535             PrintDebugString("     -> returning AC = %p, vmID = %X", rAC, pkg->rVMID);
 536         } else {
 537             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 538                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage));
 539         }
 540         break;
 541 
 542 
 543     case cGetHWNDFromAccessibleContextPackage:
 544         PrintDebugString("   type == cGetHWNDFromAccessibleContextPackage");
 545         if (bufsize == (sizeof(PackageType) + sizeof(GetHWNDFromAccessibleContextPackage))) {
 546             GetHWNDFromAccessibleContextPackage *pkg =
 547                 (GetHWNDFromAccessibleContextPackage *) (buffer + sizeof(PackageType));
 548             pkg->rHWND =
 549                 ABHandleToLong( windowsThreadEntryPoints->getHWNDFromAccessibleContext((jobject)pkg->accessibleContext) );
 550             PrintDebugString("     -> returning HWND = %p", pkg->rHWND);
 551         } else {
 552             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 553                              bufsize, sizeof(PackageType) + sizeof(GetHWNDFromAccessibleContextPackage));
 554         }
 555         break;
 556 
 557 
 558         /* ===== utility methods ===== */
 559 
 560     case cSetTextContentsPackage:
 561         PrintDebugString("   type == cSetTextContentsPackage");
 562         if (bufsize == (sizeof(PackageType) + sizeof(SetTextContentsPackage))) {
 563             SetTextContentsPackage *pkg =
 564                 (SetTextContentsPackage *) (buffer + sizeof(PackageType));
 565             pkg->rResult =
 566                 windowsThreadEntryPoints->setTextContents((jobject)pkg->accessibleContext, pkg->text);
 567             PrintDebugString("     -> returning result = %d", pkg->rResult);
 568         } else {
 569             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 570                              bufsize, sizeof(PackageType) + sizeof(SetTextContentsPackage));
 571         }
 572         break;
 573 
 574     case cGetParentWithRolePackage:
 575         if (bufsize == (sizeof(PackageType) + sizeof(GetParentWithRolePackage))) {
 576             GetParentWithRolePackage *pkg =
 577                 (GetParentWithRolePackage *) (buffer + sizeof(PackageType));
 578             rAC = windowsThreadEntryPoints->getParentWithRole((jobject)pkg->accessibleContext, pkg->role);
 579             pkg->rAccessibleContext = (JOBJECT64)rAC;
 580             PrintDebugString("   type == cGetParentWithRolePackage");
 581             PrintDebugString("     pkg->vmID: %X", pkg->vmID);
 582             PrintDebugString("     pkg->accessibleContext: %p", (jobject)pkg->accessibleContext);
 583             PrintDebugString("     pkg->role: %ls", pkg->role);
 584             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 585         } else {
 586             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 587                              bufsize, sizeof(PackageType) + sizeof(GetParentWithRolePackage));
 588         }
 589         break;
 590 
 591     case cGetTopLevelObjectPackage:
 592         PrintDebugString("   type == cGetTopLevelObjectPackage");
 593         if (bufsize == (sizeof(PackageType) + sizeof(GetTopLevelObjectPackage))) {
 594             GetTopLevelObjectPackage *pkg =
 595                 (GetTopLevelObjectPackage *) (buffer + sizeof(PackageType));
 596             rAC = windowsThreadEntryPoints->getTopLevelObject((jobject)pkg->accessibleContext);
 597             pkg->rAccessibleContext = (JOBJECT64)rAC;
 598             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 599         } else {
 600             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 601                              bufsize, sizeof(PackageType) + sizeof(GetTopLevelObjectPackage));
 602         }
 603         break;
 604 
 605     case cGetParentWithRoleElseRootPackage:
 606         PrintDebugString("   type == cGetParentWithRoleElseRootPackage");
 607         if (bufsize == (sizeof(PackageType) + sizeof(GetParentWithRoleElseRootPackage))) {
 608             GetParentWithRoleElseRootPackage *pkg =
 609                 (GetParentWithRoleElseRootPackage *) (buffer + sizeof(PackageType));
 610             rAC = windowsThreadEntryPoints->getParentWithRoleElseRoot((jobject)pkg->accessibleContext, pkg->role);
 611             pkg->rAccessibleContext = (JOBJECT64)rAC;
 612             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 613         } else {
 614             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 615                              bufsize, sizeof(PackageType) + sizeof(GetParentWithRoleElseRootPackage));
 616         }
 617         break;
 618 
 619     case cGetObjectDepthPackage:
 620         PrintDebugString("   type == cGetObjectDepthPackage");
 621         if (bufsize == (sizeof(PackageType) + sizeof(GetObjectDepthPackage))) {
 622             GetObjectDepthPackage *pkg =
 623                 (GetObjectDepthPackage *) (buffer + sizeof(PackageType));
 624             pkg->rResult =
 625                 windowsThreadEntryPoints->getObjectDepth((jobject)pkg->accessibleContext);
 626             PrintDebugString("     -> returning rResult = %d", pkg->rResult);
 627         } else {
 628             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 629                              bufsize, sizeof(PackageType) + sizeof(GetObjectDepthPackage));
 630         }
 631         break;
 632 
 633     case cGetActiveDescendentPackage:
 634         PrintDebugString("   type == cGetActiveDescendentPackage");
 635         if (bufsize == (sizeof(PackageType) + sizeof(GetActiveDescendentPackage))) {
 636             GetActiveDescendentPackage *pkg =
 637                 (GetActiveDescendentPackage *) (buffer + sizeof(PackageType));
 638             rAC = windowsThreadEntryPoints->getActiveDescendent((jobject)pkg->accessibleContext);
 639             pkg->rAccessibleContext = (JOBJECT64)rAC;
 640             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 641         } else {
 642             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 643                              bufsize, sizeof(PackageType) + sizeof(GetActiveDescendentPackage));
 644         }
 645         break;
 646 
 647     case cGetAccessibleContextAtPackage:
 648         PrintDebugString("   type == cGetAccessibleContextAtPackage");
 649         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextAtPackage))) {
 650             GetAccessibleContextAtPackage *pkg =
 651                 (GetAccessibleContextAtPackage *) (buffer + sizeof(PackageType));
 652             pkg->rAccessibleContext = (JOBJECT64)
 653                 windowsThreadEntryPoints->getAccessibleContextAt(pkg->x, pkg->y,
 654                                                                  (jobject)pkg->AccessibleContext);
 655         } else {
 656             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 657                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextAtPackage));
 658         }
 659         break;
 660 
 661     case cGetAccessibleContextWithFocusPackage:
 662         PrintDebugString("   type == cGetAccessibleContextWithFocusPackage");
 663         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage))) {
 664             GetAccessibleContextWithFocusPackage *pkg =
 665                 (GetAccessibleContextWithFocusPackage *) (buffer + sizeof(PackageType));
 666             pkg->rAccessibleContext = (JOBJECT64)
 667                 windowsThreadEntryPoints->getAccessibleContextWithFocus();
 668                         pkg->rVMID =  HandleToLong(dialogWindow);
 669         } else {
 670             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 671                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage));
 672         }
 673         break;
 674 
 675     case cGetAccessibleContextInfoPackage:
 676         PrintDebugString("   type == cGetAccessibleContextInfoPackage");
 677         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextInfoPackage))) {
 678             GetAccessibleContextInfoPackage *pkg =
 679                 (GetAccessibleContextInfoPackage *) (buffer + sizeof(PackageType));
 680             windowsThreadEntryPoints->getAccessibleContextInfo(
 681                                                                (jobject)pkg->AccessibleContext, &(pkg->rAccessibleContextInfo));
 682         } else {
 683             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 684                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextInfoPackage));
 685         }
 686         break;
 687 
 688     case cGetAccessibleChildFromContextPackage:
 689         PrintDebugString("   type == cGetAccessibleChildFromContextPackage");
 690         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleChildFromContextPackage))) {
 691             GetAccessibleChildFromContextPackage *pkg =
 692                 (GetAccessibleChildFromContextPackage *) (buffer + sizeof(PackageType));
 693             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleChildFromContext(
 694                                                                                               (jobject)pkg->AccessibleContext, pkg->childIndex);
 695         } else {
 696             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 697                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleChildFromContextPackage));
 698         }
 699         break;
 700 
 701     case cGetAccessibleParentFromContextPackage:
 702         PrintDebugString("   type == cGetAccessibleParentFromContextPackage");
 703         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleParentFromContextPackage))) {
 704             GetAccessibleParentFromContextPackage *pkg =
 705                 (GetAccessibleParentFromContextPackage *) (buffer + sizeof(PackageType));
 706             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleParentFromContext(
 707                                                                                                (jobject)pkg->AccessibleContext);
 708         } else {
 709             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 710                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleParentFromContextPackage));
 711         }
 712         break;
 713 
 714         // ------------ begin AccessibleTable packages ------------------
 715 
 716     case cGetAccessibleTableInfoPackage:
 717         PrintDebugString("   ##### type == cGetAccessibleTableInfoPackage");
 718         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableInfoPackage))) {
 719             GetAccessibleTableInfoPackage *pkg =
 720                 (GetAccessibleTableInfoPackage *) (buffer + sizeof(PackageType));
 721             windowsThreadEntryPoints->getAccessibleTableInfo((jobject)pkg->accessibleContext,
 722                                                              &(pkg->rTableInfo));
 723             PrintDebugString("   ##### processing succeeded");
 724         } else {
 725             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 726                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableInfoPackage));
 727         }
 728         break;
 729 
 730     case cGetAccessibleTableCellInfoPackage:
 731         PrintDebugString("   ##### type == cGetAccessibleTableCellInfoPackage");
 732         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableCellInfoPackage))) {
 733             GetAccessibleTableCellInfoPackage *pkg =
 734                 (GetAccessibleTableCellInfoPackage *) (buffer + sizeof(PackageType));
 735             windowsThreadEntryPoints->getAccessibleTableCellInfo((jobject)pkg->accessibleTable, pkg->row,
 736                                                                  pkg->column, &(pkg->rTableCellInfo));
 737             PrintDebugString("   ##### processing succeeded");
 738         } else {
 739             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 740                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableCellInfoPackage));
 741         }
 742         break;
 743 
 744     case cGetAccessibleTableRowHeaderPackage:
 745         PrintDebugString("   ##### type == cGetAccessibleTableRowHeaderPackage");
 746         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowHeaderPackage))) {
 747             GetAccessibleTableRowHeaderPackage *pkg =
 748                 (GetAccessibleTableRowHeaderPackage *) (buffer + sizeof(PackageType));
 749             windowsThreadEntryPoints->getAccessibleTableRowHeader((jobject)pkg->accessibleContext,
 750                                                                   &(pkg->rTableInfo));
 751             PrintDebugString("   ##### processing succeeded");
 752         } else {
 753             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 754                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowHeaderPackage));
 755         }
 756         break;
 757 
 758     case cGetAccessibleTableColumnHeaderPackage:
 759         PrintDebugString("   ##### type == cGetAccessibleTableColumnHeaderPackage");
 760         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnHeaderPackage))) {
 761             GetAccessibleTableColumnHeaderPackage *pkg =
 762                 (GetAccessibleTableColumnHeaderPackage *) (buffer + sizeof(PackageType));
 763             windowsThreadEntryPoints->getAccessibleTableColumnHeader((jobject)pkg->accessibleContext,
 764                                                                      &(pkg->rTableInfo));
 765             PrintDebugString("   ##### processing succeeded");
 766         } else {
 767             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 768                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnHeaderPackage));
 769         }
 770         break;
 771 
 772 
 773     case cGetAccessibleTableRowDescriptionPackage:
 774         PrintDebugString("   ##### type == cGetAccessibleTableRowDescriptionPackage");
 775         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowDescriptionPackage))) {
 776             GetAccessibleTableRowDescriptionPackage *pkg =
 777                 (GetAccessibleTableRowDescriptionPackage *) (buffer + sizeof(PackageType));
 778             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleTableRowDescription(
 779                                                                                                  (jobject)pkg->accessibleContext, pkg->row);
 780             PrintDebugString("   ##### processing succeeded");
 781         } else {
 782             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 783                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowDescriptionPackage));
 784         }
 785         break;
 786 
 787     case cGetAccessibleTableColumnDescriptionPackage:
 788         PrintDebugString("   ##### type == cGetAccessibleTableColumnDescriptionPackage");
 789         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnDescriptionPackage))) {
 790             GetAccessibleTableColumnDescriptionPackage *pkg =
 791                 (GetAccessibleTableColumnDescriptionPackage *) (buffer + sizeof(PackageType));
 792             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleTableColumnDescription(
 793                                                                                                     (jobject)pkg->accessibleContext, pkg->column);
 794             PrintDebugString("   ##### processing succeeded");
 795         } else {
 796             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 797                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnDescriptionPackage));
 798         }
 799         break;
 800 
 801     case cGetAccessibleTableColumnSelectionCountPackage:
 802         PrintDebugString("   ##### type == cGetAccessibleTableColumnSelectionCountPackage");
 803         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionCountPackage))) {
 804             GetAccessibleTableColumnSelectionCountPackage *pkg =
 805                 (GetAccessibleTableColumnSelectionCountPackage *) (buffer + sizeof(PackageType));
 806             pkg->rCount = windowsThreadEntryPoints->getAccessibleTableColumnSelectionCount(
 807                                                                                            (jobject)pkg->accessibleTable);
 808             PrintDebugString("   ##### processing succeeded");
 809         } else {
 810             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 811                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionCountPackage));
 812         }
 813         break;
 814 
 815     case cGetAccessibleTableRowSelectionCountPackage:
 816         PrintDebugString("   ##### type == cGetAccessibleTableRowSelectionCountPackage");
 817         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionCountPackage))) {
 818             GetAccessibleTableRowSelectionCountPackage *pkg =
 819                 (GetAccessibleTableRowSelectionCountPackage *) (buffer + sizeof(PackageType));
 820 
 821             pkg->rCount = windowsThreadEntryPoints->getAccessibleTableRowSelectionCount(
 822                                                                                         (jobject)pkg->accessibleTable);
 823 
 824             PrintDebugString("   ##### processing succeeded");
 825         } else {
 826             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 827                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionCountPackage));
 828         }
 829         break;
 830 
 831     case cIsAccessibleTableRowSelectedPackage:
 832         PrintDebugString("   ##### type == cIsAccessibleTableRowSelectedPackage");
 833         if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleTableRowSelectedPackage))) {
 834             IsAccessibleTableRowSelectedPackage *pkg =
 835                 (IsAccessibleTableRowSelectedPackage *) (buffer + sizeof(PackageType));
 836             pkg->rResult = windowsThreadEntryPoints->isAccessibleTableRowSelected(
 837                                                                                   (jobject)pkg->accessibleTable, pkg->row);
 838             PrintDebugString("   ##### processing succeeded");
 839         } else {
 840             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 841                              bufsize, sizeof(PackageType) + sizeof(IsAccessibleTableRowSelectedPackage));
 842         }
 843         break;
 844 
 845     case cIsAccessibleTableColumnSelectedPackage:
 846         PrintDebugString("   ##### type == cIsAccessibleTableColumnSelectedPackage");
 847         if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleTableColumnSelectedPackage))) {
 848             IsAccessibleTableColumnSelectedPackage *pkg =
 849                 (IsAccessibleTableColumnSelectedPackage *) (buffer + sizeof(PackageType));
 850             pkg->rResult = windowsThreadEntryPoints->isAccessibleTableColumnSelected(
 851                                                                                      (jobject)pkg->accessibleTable, pkg->column);
 852             PrintDebugString("   ##### processing succeeded");
 853         } else {
 854             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 855                              bufsize, sizeof(PackageType) + sizeof(IsAccessibleTableColumnSelectedPackage));
 856         }
 857         break;
 858 
 859     case cGetAccessibleTableColumnSelectionsPackage:
 860         PrintDebugString("   ##### type == cGetAccessibleTableColumnSelectionsPackage");
 861         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionsPackage))) {
 862             GetAccessibleTableColumnSelectionsPackage *pkg =
 863                 (GetAccessibleTableColumnSelectionsPackage *) (buffer + sizeof(PackageType));
 864             PrintDebugString("     ##### cGetAccessibleTableColumnSelectionsPackage count=%d", pkg->count);
 865             windowsThreadEntryPoints->getAccessibleTableColumnSelections(
 866                                                                          (jobject)pkg->accessibleTable, pkg->count, pkg->rSelections);
 867 
 868             for (int i = 0; i < pkg->count; i++) {
 869                 PrintDebugString("     ##### cGetAccessibleTableColumnSelectionsPackage(%d)=%d", i, pkg->rSelections[i]);
 870             }
 871 
 872             PrintDebugString("   ##### processing succeeded");
 873         } else {
 874             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 875                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionsPackage));
 876         }
 877         break;
 878 
 879 
 880     case cGetAccessibleTableRowSelectionsPackage:
 881         PrintDebugString("   ##### type == cGetAccessibleTableRowSelectionsPackage");
 882         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionsPackage))) {
 883             GetAccessibleTableRowSelectionsPackage *pkg =
 884                 (GetAccessibleTableRowSelectionsPackage *) (buffer + sizeof(PackageType));
 885             windowsThreadEntryPoints->getAccessibleTableRowSelections(
 886                                                                       (jobject)pkg->accessibleTable, pkg->count, pkg->rSelections);
 887             PrintDebugString("   ##### processing succeeded");
 888         } else {
 889             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 890                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionsPackage));
 891         }
 892         break;
 893 
 894     case cGetAccessibleTableRowPackage:
 895         PrintDebugString("   ##### type == cGetAccessibleTableRowPackage");
 896         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowPackage))) {
 897             GetAccessibleTableRowPackage *pkg =
 898                 (GetAccessibleTableRowPackage *) (buffer + sizeof(PackageType));
 899             pkg->rRow = windowsThreadEntryPoints->getAccessibleTableRow(
 900                                                                         (jobject)pkg->accessibleTable, pkg->index);
 901             PrintDebugString("   ##### processing succeeded");
 902         } else {
 903             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 904                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowPackage));
 905         }
 906         break;
 907 
 908     case cGetAccessibleTableColumnPackage:
 909         PrintDebugString("   ##### type == cGetAccessibleTableColumnPackage");
 910         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnPackage))) {
 911             GetAccessibleTableColumnPackage *pkg =
 912                 (GetAccessibleTableColumnPackage *) (buffer + sizeof(PackageType));
 913             pkg->rColumn = windowsThreadEntryPoints->getAccessibleTableColumn(
 914                                                                               (jobject)pkg->accessibleTable, pkg->index);
 915             PrintDebugString("   ##### processing succeeded");
 916         } else {
 917             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 918                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnPackage));
 919         }
 920         break;
 921 
 922     case cGetAccessibleTableIndexPackage:
 923         PrintDebugString("   ##### type == cGetAccessibleTableIndexPackage");
 924         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableIndexPackage))) {
 925             GetAccessibleTableIndexPackage *pkg =
 926                 (GetAccessibleTableIndexPackage *) (buffer + sizeof(PackageType));
 927             pkg->rIndex = windowsThreadEntryPoints->getAccessibleTableIndex(
 928                                                                             (jobject)pkg->accessibleTable, pkg->row, pkg->column);
 929             PrintDebugString("   ##### processing succeeded");
 930         } else {
 931             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 932                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableIndexPackage));
 933         }
 934         break;
 935 
 936         // ------------ end AccessibleTable packages ------------------
 937 
 938 
 939         // ------------ begin AccessibleRelationSet packages ------------------
 940 
 941     case cGetAccessibleRelationSetPackage:
 942         PrintDebugString("   ##### type == cGetAccessibleRelationSetPackage");
 943         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleRelationSetPackage))) {
 944             GetAccessibleRelationSetPackage *pkg =
 945                 (GetAccessibleRelationSetPackage *) (buffer + sizeof(PackageType));
 946             windowsThreadEntryPoints->getAccessibleRelationSet(
 947                                                                (jobject)pkg->accessibleContext, &(pkg->rAccessibleRelationSetInfo));
 948             PrintDebugString("   ##### processing succeeded");
 949         } else {
 950             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 951                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleRelationSetPackage));
 952         }
 953         break;
 954 
 955         // ------------ end AccessibleRelationSet packages ------------------
 956 
 957         // ------------ begin AccessibleHypertext packages ------------------
 958 
 959     case cGetAccessibleHypertextPackage:
 960         PrintDebugString("   ##### type == cGetAccessibleHypertextPackage");
 961         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextPackage))) {
 962             GetAccessibleHypertextPackage *pkg =
 963                 (GetAccessibleHypertextPackage *) (buffer + sizeof(PackageType));
 964             windowsThreadEntryPoints->getAccessibleHypertext(
 965                                                              (jobject)pkg->accessibleContext, &(pkg->rAccessibleHypertextInfo));
 966             PrintDebugString("   ##### processing succeeded");
 967         } else {
 968             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 969                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextPackage));
 970         }
 971         break;
 972 
 973     case cActivateAccessibleHyperlinkPackage:
 974         PrintDebugString("   ##### type == cActivateAccessibleHyperlinkPackage");
 975         if (bufsize == (sizeof(PackageType) + sizeof(ActivateAccessibleHyperlinkPackage))) {
 976             ActivateAccessibleHyperlinkPackage *pkg =
 977                 (ActivateAccessibleHyperlinkPackage *) (buffer + sizeof(PackageType));
 978             pkg->rResult = windowsThreadEntryPoints->activateAccessibleHyperlink(
 979                                                                                  (jobject)pkg->accessibleContext, (jobject)pkg->accessibleHyperlink);
 980             PrintDebugString("   ##### processing succeeded");
 981         } else {
 982             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 983                              bufsize, sizeof(PackageType) + sizeof(ActivateAccessibleHyperlinkPackage));
 984         }
 985         break;
 986 
 987     case cGetAccessibleHyperlinkCountPackage:
 988         PrintDebugString("   ##### type == cGetAccessibleHyperlinkCountPackage");
 989         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHyperlinkCountPackage))) {
 990             GetAccessibleHyperlinkCountPackage *pkg =
 991                 (GetAccessibleHyperlinkCountPackage *) (buffer + sizeof(PackageType));
 992             pkg->rLinkCount = windowsThreadEntryPoints->getAccessibleHyperlinkCount(
 993                                                                                     (jobject)pkg->accessibleContext);
 994             PrintDebugString("   ##### processing succeeded: pkg->rLinkCount = %d", pkg->rLinkCount);
 995         } else {
 996             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 997                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHyperlinkCountPackage));
 998         }
 999         break;
1000 
1001     case cGetAccessibleHypertextExtPackage:
1002         PrintDebugString("   ##### type == cGetAccessibleHypertextExtPackage");
1003         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextExtPackage))) {
1004             GetAccessibleHypertextExtPackage *pkg =
1005                 (GetAccessibleHypertextExtPackage *) (buffer + sizeof(PackageType));
1006             pkg->rSuccess = windowsThreadEntryPoints->getAccessibleHypertextExt(
1007                                                                                 (jobject)pkg->accessibleContext, pkg->startIndex, &(pkg->rAccessibleHypertextInfo));
1008             PrintDebugString("   ##### processing succeeded");
1009         } else {
1010             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1011                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextExtPackage));
1012         }
1013         break;
1014 
1015     case cGetAccessibleHypertextLinkIndexPackage:
1016         PrintDebugString("   ##### type == cGetAccessibleHypertextLinkIndexPackage");
1017         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextLinkIndexPackage))) {
1018             GetAccessibleHypertextLinkIndexPackage *pkg =
1019                 (GetAccessibleHypertextLinkIndexPackage *) (buffer + sizeof(PackageType));
1020             pkg->rLinkIndex = windowsThreadEntryPoints->getAccessibleHypertextLinkIndex(
1021                                                                                         (jobject)pkg->hypertext, pkg->charIndex);
1022             PrintDebugString("   ##### processing succeeded");
1023         } else {
1024             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1025                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextLinkIndexPackage));
1026         }
1027         break;
1028 
1029     case cGetAccessibleHyperlinkPackage:
1030         PrintDebugString("   ##### type == cGetAccessibleHyperlinkPackage");
1031         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHyperlinkPackage))) {
1032             GetAccessibleHyperlinkPackage *pkg =
1033                 (GetAccessibleHyperlinkPackage *) (buffer + sizeof(PackageType));
1034             windowsThreadEntryPoints->getAccessibleHyperlink((jobject)pkg->hypertext, pkg->linkIndex,
1035                                                              &(pkg->rAccessibleHyperlinkInfo));
1036             PrintDebugString("   ##### processing succeeded");
1037         } else {
1038             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1039                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHyperlinkPackage));
1040         }
1041         break;
1042 
1043         // ------------ end AccessibleHypertext packages
1044 
1045         // ------------ begin Accessible KeyBindings, Icons and Actions
1046 
1047     case cGetAccessibleKeyBindingsPackage:
1048         PrintDebugString("   ##### type == cGetAccessibleKeyBindingsPackage");
1049         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleKeyBindingsPackage))) {
1050             GetAccessibleKeyBindingsPackage *pkg =
1051                 (GetAccessibleKeyBindingsPackage *) (buffer + sizeof(PackageType));
1052             windowsThreadEntryPoints->getAccessibleKeyBindings (
1053                                                                 (jobject)pkg->accessibleContext, &(pkg->rAccessibleKeyBindings));
1054             PrintDebugString("   ##### processing succeeded");
1055         } else {
1056             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1057                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleKeyBindingsPackage));
1058         }
1059         break;
1060 
1061     case cGetAccessibleIconsPackage:
1062         PrintDebugString("   ##### type == cGetAccessibleIconsPackage");
1063         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleIconsPackage))) {
1064             GetAccessibleIconsPackage *pkg =
1065                 (GetAccessibleIconsPackage *) (buffer + sizeof(PackageType));
1066             windowsThreadEntryPoints->getAccessibleIcons (
1067                                                           (jobject)pkg->accessibleContext, &(pkg->rAccessibleIcons));
1068             PrintDebugString("   ##### processing succeeded");
1069         } else {
1070             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1071                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleIconsPackage));
1072         }
1073         break;
1074 
1075 
1076     case cGetAccessibleActionsPackage:
1077         PrintDebugString("   ##### type == cGetAccessibleActionsPackage");
1078         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleActionsPackage))) {
1079             GetAccessibleActionsPackage *pkg =
1080                 (GetAccessibleActionsPackage *) (buffer + sizeof(PackageType));
1081             windowsThreadEntryPoints->getAccessibleActions (
1082                                                             (jobject)pkg->accessibleContext, &(pkg->rAccessibleActions));
1083             PrintDebugString("   ##### processing succeeded");
1084         } else {
1085             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1086                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleActionsPackage));
1087         }
1088         break;
1089 
1090     case cDoAccessibleActionsPackage:
1091         PrintDebugString("   ##### type == cDoAccessibleActionsPackage");
1092         if (bufsize == (sizeof(PackageType) + sizeof(DoAccessibleActionsPackage))) {
1093             DoAccessibleActionsPackage *pkg =
1094                 (DoAccessibleActionsPackage *) (buffer + sizeof(PackageType));
1095             pkg->rResult =
1096                 windowsThreadEntryPoints->doAccessibleActions((jobject)pkg->accessibleContext, &(pkg->actionsToDo),
1097                                                               &(pkg->failure));
1098             PrintDebugString("   ##### processing succeeded");
1099         } else {
1100             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1101                              bufsize, sizeof(PackageType) + sizeof(DoAccessibleActionsPackage));
1102         }
1103         break;
1104 
1105         // ------------ begin addtional methods for Teton
1106 
1107     case cGetVirtualAccessibleNamePackage:
1108         PrintDebugString("   ##### type == GetVirtualAccessibleNamePackage");
1109         if (bufsize == (sizeof(PackageType) + sizeof(GetVirtualAccessibleNamePackage))) {
1110             GetVirtualAccessibleNamePackage *pkg =
1111                 (GetVirtualAccessibleNamePackage *) (buffer + sizeof(PackageType));
1112             windowsThreadEntryPoints->getVirtualAccessibleName ((const jobject)pkg->accessibleContext,
1113                                                              pkg->rName,
1114                                                              pkg->len);
1115             PrintDebugString("   ##### processing succeeded");
1116         } else {
1117             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1118                              bufsize, sizeof(PackageType) + sizeof(GetVirtualAccessibleNamePackage));
1119         }
1120         break;
1121 
1122     case cRequestFocusPackage:
1123         PrintDebugString("   ##### type == RequestFocusPackage");
1124         if (bufsize == (sizeof(PackageType) + sizeof(RequestFocusPackage))) {
1125             RequestFocusPackage *pkg =
1126                 (RequestFocusPackage *) (buffer + sizeof(PackageType));
1127             windowsThreadEntryPoints->requestFocus (
1128                                                     (jobject)pkg->accessibleContext);
1129             PrintDebugString("   ##### processing succeeded");
1130         } else {
1131             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1132                              bufsize, sizeof(PackageType) + sizeof(RequestFocusPackage));
1133         }
1134         break;
1135 
1136     case cSelectTextRangePackage:
1137         PrintDebugString("   ##### type == SelectTextRangePackage");
1138         if (bufsize == (sizeof(PackageType) + sizeof(SelectTextRangePackage))) {
1139             SelectTextRangePackage *pkg =
1140                 (SelectTextRangePackage *) (buffer + sizeof(PackageType));
1141             windowsThreadEntryPoints->selectTextRange (
1142                                                        (jobject)pkg->accessibleContext, pkg->startIndex, pkg->endIndex);
1143             PrintDebugString("   ##### processing succeeded");
1144         } else {
1145             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1146                              bufsize, sizeof(PackageType) + sizeof(SelectTextRangePackage));
1147         }
1148         break;
1149 
1150     case cGetTextAttributesInRangePackage:
1151         PrintDebugString("   ##### type == GetTextAttributesInRangePackage");
1152         if (bufsize == (sizeof(PackageType) + sizeof(GetTextAttributesInRangePackage))) {
1153             GetTextAttributesInRangePackage *pkg =
1154                 (GetTextAttributesInRangePackage *) (buffer + sizeof(PackageType));
1155             windowsThreadEntryPoints->getTextAttributesInRange (
1156                                                                 (jobject)pkg->accessibleContext, pkg->startIndex, pkg->endIndex,
1157                                                                 (AccessibleTextAttributesInfo *)&(pkg->attributes),
1158                                                                 &(pkg->rLength));
1159             PrintDebugString("   ##### processing succeeded");
1160         } else {
1161             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1162                              bufsize, sizeof(PackageType) + sizeof(GetTextAttributesInRangePackage));
1163         }
1164         break;
1165 
1166 
1167     case cGetVisibleChildrenCountPackage:
1168         PrintDebugString("   ##### type == GetVisibleChildrenCountPackage");
1169         if (bufsize == (sizeof(PackageType) + sizeof(GetVisibleChildrenCountPackage))) {
1170             GetVisibleChildrenCountPackage *pkg =
1171                 (GetVisibleChildrenCountPackage *) (buffer + sizeof(PackageType));
1172             pkg->rChildrenCount = windowsThreadEntryPoints->getVisibleChildrenCount ((jobject)pkg->accessibleContext);
1173 
1174             PrintDebugString("   ##### processing succeeded");
1175         } else {
1176             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1177                              bufsize, sizeof(PackageType) + sizeof(GetVisibleChildrenCountPackage));
1178         }
1179         break;
1180 
1181     case cGetVisibleChildrenPackage:
1182         PrintDebugString("   ##### type == GetVisibleChildrenPackage");
1183         if (bufsize == (sizeof(PackageType) + sizeof(GetVisibleChildrenPackage))) {
1184             GetVisibleChildrenPackage *pkg =
1185                 (GetVisibleChildrenPackage *) (buffer + sizeof(PackageType));
1186             pkg->rSuccess = windowsThreadEntryPoints->getVisibleChildren ((jobject)pkg->accessibleContext,
1187                                                                           pkg->startIndex,
1188                                                                           &(pkg->rVisibleChildrenInfo));
1189 
1190             PrintDebugString("   ##### processing succeeded");
1191         } else {
1192             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1193                              bufsize, sizeof(PackageType) + sizeof(GetVisibleChildrenPackage));
1194         }
1195         break;
1196 
1197     case cSetCaretPositionPackage:
1198         PrintDebugString("   ##### type == SetCaretPositionPackage");
1199         if (bufsize == (sizeof(PackageType) + sizeof(SetCaretPositionPackage))) {
1200             SetCaretPositionPackage *pkg =
1201                 (SetCaretPositionPackage *) (buffer + sizeof(PackageType));
1202             windowsThreadEntryPoints->setCaretPosition (
1203                                                         (jobject)pkg->accessibleContext, pkg->position);
1204             PrintDebugString("   ##### processing succeeded");
1205         } else {
1206             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1207                              bufsize, sizeof(PackageType) + sizeof(SetCaretPositionPackage));
1208         }
1209         break;
1210 
1211         // ------------ end additional methods for Teton
1212 
1213         // ------------ end Accessible KeyBindings, Icons and Actions
1214 
1215         // ------------ Accessible Text packages ------------------
1216 
1217     case cGetAccessibleTextInfoPackage:
1218         PrintDebugString("   type == cGetAccessibleTextInfoPackage");
1219         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage))) {
1220             GetAccessibleTextInfoPackage *pkg =
1221                 (GetAccessibleTextInfoPackage *) (buffer + sizeof(PackageType));
1222             windowsThreadEntryPoints->getAccessibleTextInfo((jobject)pkg->AccessibleContext,
1223                                                             &(pkg->rTextInfo), pkg->x, pkg->y);
1224         } else {
1225             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1226                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage));
1227         }
1228         break;
1229 
1230     case cGetAccessibleTextItemsPackage:
1231         PrintDebugString("   type == cGetAccessibleTextItemsPackage");
1232         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextItemsPackage))) {
1233             GetAccessibleTextItemsPackage *pkg =
1234                 (GetAccessibleTextItemsPackage *) (buffer + sizeof(PackageType));
1235             windowsThreadEntryPoints->getAccessibleTextItems((jobject)pkg->AccessibleContext,
1236                                                              &(pkg->rTextItemsInfo), pkg->index);
1237         } else {
1238             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1239                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage));
1240         }
1241         break;
1242 
1243     case cGetAccessibleTextSelectionInfoPackage:
1244         PrintDebugString("   type == cGetAccessibleTextSelectionInfoPackage");
1245         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextSelectionInfoPackage))) {
1246             GetAccessibleTextSelectionInfoPackage *pkg =
1247                 (GetAccessibleTextSelectionInfoPackage *) (buffer + sizeof(PackageType));
1248             windowsThreadEntryPoints->getAccessibleTextSelectionInfo(
1249                                                                      (jobject)pkg->AccessibleContext, &(pkg->rTextSelectionItemsInfo));
1250         } else {
1251             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1252                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextSelectionInfoPackage));
1253         }
1254         break;
1255 
1256     case cGetAccessibleTextAttributeInfoPackage:
1257         PrintDebugString("   type == cGetAccessibleTextAttributeInfoPackage");
1258         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextAttributeInfoPackage))) {
1259             GetAccessibleTextAttributeInfoPackage *pkg =
1260                 (GetAccessibleTextAttributeInfoPackage *) (buffer + sizeof(PackageType));
1261             windowsThreadEntryPoints->getAccessibleTextAttributes(
1262                                                                   (jobject)pkg->AccessibleContext, pkg->index, (AccessibleTextAttributesInfo *) &(pkg->rAttributeInfo));
1263         } else {
1264             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1265                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextAttributeInfoPackage));
1266         }
1267         break;
1268 
1269     case cGetAccessibleTextRectInfoPackage:
1270         PrintDebugString("   type == cGetAccessibleTextRectInfoPackage");
1271         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextRectInfoPackage))) {
1272             GetAccessibleTextRectInfoPackage *pkg =
1273                 (GetAccessibleTextRectInfoPackage *) (buffer + sizeof(PackageType));
1274             windowsThreadEntryPoints->getAccessibleTextRect((jobject)pkg->AccessibleContext,
1275                                                             &(pkg->rTextRectInfo), pkg->index);
1276         } else {
1277             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1278                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextRectInfoPackage));
1279         }
1280         break;
1281 
1282     case cGetCaretLocationPackage:
1283         PrintDebugString("   type == cGetCaretLocationPackage");
1284         if (bufsize == (sizeof(PackageType) + sizeof(GetCaretLocationPackage))) {
1285             GetCaretLocationPackage *pkg =
1286                 (GetCaretLocationPackage *) (buffer + sizeof(PackageType));
1287             windowsThreadEntryPoints->getCaretLocation((jobject)pkg->AccessibleContext,
1288                                                             &(pkg->rTextRectInfo), pkg->index);
1289         } else {
1290             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1291                              bufsize, sizeof(PackageType) + sizeof(GetCaretLocationPackage));
1292         }
1293         break;
1294 
1295     case cGetAccessibleTextLineBoundsPackage:
1296         PrintDebugString("   type == cGetAccessibleTextLineBoundsPackage");
1297         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextLineBoundsPackage))) {
1298             GetAccessibleTextLineBoundsPackage *pkg =
1299                 (GetAccessibleTextLineBoundsPackage *) (buffer + sizeof(PackageType));
1300             windowsThreadEntryPoints->getAccessibleTextLineBounds((jobject)pkg->AccessibleContext,
1301                                                                   pkg->index, &(pkg->rLineStart), &(pkg->rLineEnd));
1302         } else {
1303             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1304                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextLineBoundsPackage));
1305         }
1306         break;
1307 
1308     case cGetAccessibleTextRangePackage:
1309         PrintDebugString("   type == cGetAccessibleTextRangePackage");
1310         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextRangePackage))) {
1311             GetAccessibleTextRangePackage *pkg =
1312                 (GetAccessibleTextRangePackage *) (buffer + sizeof(PackageType));
1313             windowsThreadEntryPoints->getAccessibleTextRange((jobject)pkg->AccessibleContext,
1314                                                              pkg->start, pkg->end, (wchar_t *) &(pkg->rText), (sizeof(pkg->rText) / sizeof(wchar_t)));
1315         } else {
1316             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1317                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextRangePackage));
1318         }
1319         break;
1320 
1321 
1322         // ------------ Accessible Value packages ------------------
1323 
1324     case cGetCurrentAccessibleValueFromContextPackage:
1325         PrintDebugString("   type == cGetCurrentAccessibleValueFromContextPackage");
1326         if (bufsize == (sizeof(PackageType) + sizeof(GetCurrentAccessibleValueFromContextPackage))) {
1327             GetCurrentAccessibleValueFromContextPackage *pkg =
1328                 (GetCurrentAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType));
1329             windowsThreadEntryPoints->getCurrentAccessibleValueFromContext((jobject)pkg->AccessibleContext,
1330                                                                            (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t)));
1331         } else {
1332             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1333                              bufsize, sizeof(PackageType) + sizeof(GetCurrentAccessibleValueFromContextPackage));
1334         }
1335         break;
1336 
1337     case cGetMaximumAccessibleValueFromContextPackage:
1338         PrintDebugString("   type == cGetMaximumAccessibleValueFromContextPackage");
1339         if (bufsize == (sizeof(PackageType) + sizeof(GetMaximumAccessibleValueFromContextPackage))) {
1340             GetMaximumAccessibleValueFromContextPackage *pkg =
1341                 (GetMaximumAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType));
1342             windowsThreadEntryPoints->getMaximumAccessibleValueFromContext((jobject)pkg->AccessibleContext,
1343                                                                            (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t)));
1344         } else {
1345             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1346                              bufsize, sizeof(PackageType) + sizeof(GetMaximumAccessibleValueFromContextPackage));
1347         }
1348         break;
1349 
1350     case cGetMinimumAccessibleValueFromContextPackage:
1351         PrintDebugString("   type == cGetMinimumAccessibleValueFromContextPackage");
1352         if (bufsize == (sizeof(PackageType) + sizeof(GetMinimumAccessibleValueFromContextPackage))) {
1353             GetMinimumAccessibleValueFromContextPackage *pkg =
1354                 (GetMinimumAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType));
1355             windowsThreadEntryPoints->getMinimumAccessibleValueFromContext((jobject)pkg->AccessibleContext,
1356                                                                            (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t)));
1357         } else {
1358             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1359                              bufsize, sizeof(PackageType) + sizeof(GetMinimumAccessibleValueFromContextPackage));
1360         }
1361         break;
1362 
1363         // ------------ Accessible Selection packages ------------------
1364 
1365     case cAddAccessibleSelectionFromContextPackage:
1366         PrintDebugString("   type == cAddAccessibleSelectionFromContextPackage");
1367         if (bufsize == (sizeof(PackageType) + sizeof(AddAccessibleSelectionFromContextPackage))) {
1368             AddAccessibleSelectionFromContextPackage *pkg =
1369                 (AddAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1370             windowsThreadEntryPoints->addAccessibleSelectionFromContext((jobject)pkg->AccessibleContext,
1371                                                                         pkg->index);
1372         } else {
1373             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1374                              bufsize, sizeof(PackageType) + sizeof(AddAccessibleSelectionFromContextPackage));
1375         }
1376         break;
1377 
1378     case cClearAccessibleSelectionFromContextPackage:
1379         PrintDebugString("   type == cClearAccessibleSelectionFromContextPackage");
1380         if (bufsize == (sizeof(PackageType) + sizeof(ClearAccessibleSelectionFromContextPackage))) {
1381             ClearAccessibleSelectionFromContextPackage *pkg =
1382                 (ClearAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1383             windowsThreadEntryPoints->clearAccessibleSelectionFromContext((jobject)pkg->AccessibleContext);
1384         } else {
1385             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1386                              bufsize, sizeof(PackageType) + sizeof(ClearAccessibleSelectionFromContextPackage));
1387         }
1388         break;
1389 
1390     case cGetAccessibleSelectionFromContextPackage:
1391         PrintDebugString("   type == cGetAccessibleSelectionFromContextPackage");
1392         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleSelectionFromContextPackage))) {
1393             GetAccessibleSelectionFromContextPackage *pkg =
1394                 (GetAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1395             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleSelectionFromContext(
1396                                                                                                   (jobject)pkg->AccessibleContext, pkg->index);
1397         } else {
1398             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1399                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleSelectionFromContextPackage));
1400         }
1401         break;
1402 
1403     case cGetAccessibleSelectionCountFromContextPackage:
1404         PrintDebugString("   type == cGetAccessibleSelectionCountFromContextPackage");
1405         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleSelectionCountFromContextPackage))) {
1406             GetAccessibleSelectionCountFromContextPackage *pkg =
1407                 (GetAccessibleSelectionCountFromContextPackage *) (buffer + sizeof(PackageType));
1408             pkg->rCount = windowsThreadEntryPoints->getAccessibleSelectionCountFromContext(
1409                                                                                            (jobject)pkg->AccessibleContext);
1410         } else {
1411             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1412                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleSelectionCountFromContextPackage));
1413         }
1414         break;
1415 
1416     case cIsAccessibleChildSelectedFromContextPackage:
1417         PrintDebugString("   type == cIsAccessibleChildSelectedFromContextPackage");
1418         if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleChildSelectedFromContextPackage))) {
1419             IsAccessibleChildSelectedFromContextPackage *pkg =
1420                 (IsAccessibleChildSelectedFromContextPackage *) (buffer + sizeof(PackageType));
1421             pkg->rResult = windowsThreadEntryPoints->isAccessibleChildSelectedFromContext(
1422                                                                                           (jobject)pkg->AccessibleContext, pkg->index);
1423         } else {
1424             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1425                              bufsize, sizeof(PackageType) + sizeof(IsAccessibleChildSelectedFromContextPackage));
1426         }
1427         break;
1428 
1429     case cRemoveAccessibleSelectionFromContextPackage:
1430         PrintDebugString("   type == cRemoveAccessibleSelectionFromContextPackage");
1431         if (bufsize == (sizeof(PackageType) + sizeof(RemoveAccessibleSelectionFromContextPackage))) {
1432             RemoveAccessibleSelectionFromContextPackage *pkg =
1433                 (RemoveAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1434             windowsThreadEntryPoints->removeAccessibleSelectionFromContext((jobject)pkg->AccessibleContext,
1435                                                                            pkg->index);
1436         } else {
1437             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1438                              bufsize, sizeof(PackageType) + sizeof(RemoveAccessibleSelectionFromContextPackage));
1439         }
1440         break;
1441 
1442     case cSelectAllAccessibleSelectionFromContextPackage:
1443         PrintDebugString("   type == cSelectAllAccessibleSelectionFromContextPackage");
1444         if (bufsize == (sizeof(PackageType) + sizeof(SelectAllAccessibleSelectionFromContextPackage))) {
1445             SelectAllAccessibleSelectionFromContextPackage *pkg =
1446                 (SelectAllAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1447             windowsThreadEntryPoints->selectAllAccessibleSelectionFromContext((jobject)pkg->AccessibleContext);
1448         } else {
1449             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1450                              bufsize, sizeof(PackageType) + sizeof(SelectAllAccessibleSelectionFromContextPackage));
1451         }
1452         break;
1453 
1454 
1455         // ------------ event notification management packages ------------------
1456 
1457     case cAddJavaEventNotificationPackage:
1458         PrintDebugString("   type = cAddJavaEventNotificationPackage");
1459         if (bufsize == (sizeof(PackageType) + sizeof(AddJavaEventNotificationPackage))) {
1460             AddJavaEventNotificationPackage *pkg =
1461                 (AddJavaEventNotificationPackage *) (buffer + sizeof(PackageType));
1462             addJavaEventNotification(pkg->type, (HWND)ABLongToHandle( pkg->DLLwindow ) );
1463         } else {
1464             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1465                              bufsize, sizeof(PackageType) + sizeof(AddJavaEventNotificationPackage));
1466         }
1467         break;
1468 
1469     case cRemoveJavaEventNotificationPackage:
1470         PrintDebugString("   type = cRemoveJavaEventNotificationPackage");
1471         if (bufsize == (sizeof(PackageType) + sizeof(RemoveJavaEventNotificationPackage))) {
1472             RemoveJavaEventNotificationPackage *pkg =
1473                 (RemoveJavaEventNotificationPackage *) (buffer + sizeof(PackageType));
1474             removeJavaEventNotification(pkg->type, (HWND)ABLongToHandle( pkg->DLLwindow ));
1475         } else {
1476             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1477                              bufsize, sizeof(PackageType) + sizeof(RemoveJavaEventNotificationPackage));
1478         }
1479         break;
1480 
1481     case cAddAccessibilityEventNotificationPackage:
1482         PrintDebugString("   type = cAddAccessibilityEventNotificationPackage");
1483         if (bufsize == (sizeof(PackageType) + sizeof(AddAccessibilityEventNotificationPackage))) {
1484             AddAccessibilityEventNotificationPackage *pkg =
1485                 (AddAccessibilityEventNotificationPackage *) (buffer + sizeof(PackageType));
1486             addAccessibilityEventNotification(pkg->type, (HWND)ABLongToHandle(pkg->DLLwindow));
1487         } else {
1488             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1489                              bufsize, sizeof(PackageType) + sizeof(AddAccessibilityEventNotificationPackage));
1490         }
1491         break;
1492 
1493     case cRemoveAccessibilityEventNotificationPackage:
1494         PrintDebugString("   type = cRemoveAccessibilityEventNotificationPackage");
1495         if (bufsize == (sizeof(PackageType) + sizeof(RemoveAccessibilityEventNotificationPackage))) {
1496             RemoveAccessibilityEventNotificationPackage *pkg =
1497                 (RemoveAccessibilityEventNotificationPackage *) (buffer + sizeof(PackageType));
1498             removeAccessibilityEventNotification(pkg->type, (HWND)ABLongToHandle(pkg->DLLwindow));
1499         } else {
1500             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1501                              bufsize, sizeof(PackageType) + sizeof(RemoveAccessibilityEventNotificationPackage));
1502         }
1503         break;
1504 
1505     default:
1506         PrintDebugString("   processing FAILED!! -> don't know how to handle type = %X", *type);
1507         returnVal = -1;
1508         break;
1509     }
1510 
1511     PrintDebugString("   package processing completed");
1512     return returnVal;
1513 }
1514 
1515 
1516 // -----------------------------
1517 
1518 
1519 /**
1520  * MemoryMappedFileCreated
1521  *          - WindowsDLL letting us know it's created a memory-mapped file
1522  *            for IPC.  We need to open it and write a magic string into
1523  *            it to let the WindowsDLL know all is OK.  Also we need to
1524  *            set up our own data structures to communicate with the
1525  *            WindowsDLL
1526  *
1527  */
1528 LRESULT
1529 JavaAccessBridge::MemoryMappedFileCreated(HWND ATBridgeDLLWindow, char *filename) {
1530     PrintDebugString("  in MemoryMappedFileCreated(%p, %s)!", ATBridgeDLLWindow, filename);
1531     AccessBridgeATInstance *newAT =
1532         new AccessBridgeATInstance(dialogWindow, ATBridgeDLLWindow, filename, ATs);
1533     PrintDebugString("    just created a new ATInstance = %p, old = %p", newAT, ATs);
1534     ATs = newAT;
1535 
1536     LRESULT returnVal = ATs->initiateIPC();
1537     if (returnVal == 0) {
1538         PrintDebugString("  Successfully initiated IPC with AT!!!");
1539     } else {
1540         PrintDebugString("  ERROR: Failed to initiate IPC with AT!!!");
1541     }
1542 
1543     return returnVal;
1544 }
1545 
1546 
1547 /**
1548  * WindowsATDestroyed - lets the JavaABDLL know a Windows AT disappeared
1549  *
1550  */
1551 void
1552 JavaAccessBridge::WindowsATDestroyed(HWND ATBridgeDLLWindow) {
1553     PrintDebugString("\r\nin JavaAccessBridge::WindowsATDestroyed(%p)", ATBridgeDLLWindow);
1554     if (ATs == (AccessBridgeATInstance *) 0) {
1555         PrintDebugString("  ERROR!! -> ATs == 0! (shouldn't happen here)");
1556         return;
1557     }
1558 
1559     AccessBridgeATInstance *currentAT = ATs;
1560     AccessBridgeATInstance *previousAT = ATs;
1561     if (ATs->winAccessBridgeWindow == ATBridgeDLLWindow) {
1562         ATs = ATs->nextATInstance;
1563         // remove event notification for this AT
1564         removeJavaEventNotification(currentAT->javaEventMask, ATBridgeDLLWindow);
1565         removeAccessibilityEventNotification(currentAT->accessibilityEventMask, ATBridgeDLLWindow);
1566         delete currentAT;
1567         PrintDebugString("  data structures successfully removed");
1568     } else {
1569         while (currentAT != (AccessBridgeATInstance *) NULL) {
1570             if (currentAT->winAccessBridgeWindow == ATBridgeDLLWindow) {
1571                 previousAT->nextATInstance = currentAT->nextATInstance;
1572                 delete currentAT;
1573                 PrintDebugString("  data structures successfully removed");
1574                 return;
1575             } else {
1576                 previousAT = currentAT;
1577                 currentAT = currentAT->nextATInstance;
1578             }
1579         }
1580         PrintDebugString("  ERROR!! couldn't find matching data structures!");
1581     }
1582 }
1583 
1584 
1585 // -----------------------------
1586 
1587 
1588 /**
1589  * releaseJavaObject - lets the JavaVM know it can release the Java Object
1590  *
1591  * Note: once you have made this call, the JavaVM will garbage collect
1592  * the jobject you pass in.  If you later use that jobject in another
1593  * call, you will cause all maner of havoc!
1594  *
1595  */
1596 void
1597 JavaAccessBridge::releaseJavaObject(jobject object) {
1598     PrintDebugString("In JavaAccessBridge::releaseJavaObject");
1599     PrintDebugString("  object X: %p", object);
1600     if (windowsThreadJNIEnv != (JNIEnv *) 0) {
1601         windowsThreadJNIEnv->DeleteGlobalRef(object);
1602         PrintDebugString("  global reference deleted.", object);
1603     } else {
1604         PrintDebugString("  Error! windowsThreadJNIEnv == 0");
1605     }
1606 }
1607 
1608 // -----------------------------
1609 
1610 /**
1611  * addJavaEventNotification - this AT now wants this type of events
1612  *
1613  */
1614 void
1615 JavaAccessBridge::addJavaEventNotification(jlong type, HWND DLLwindow) {
1616     // walk through list of ATs, find this one and add this type
1617     // and, if we weren't listening for these before, ask Java for 'em
1618     PrintDebugString("  adding Java event type %016I64X to HWND %p", type, DLLwindow);
1619     AccessBridgeATInstance *ati = ATs;
1620     long globalEventMask = 0;
1621     while (ati != (AccessBridgeATInstance *) 0) {
1622         if (ati->winAccessBridgeWindow == DLLwindow) {
1623             ati->javaEventMask |= type;
1624             PrintDebugString("  found HWND, javaEventMask now is %X", ati->javaEventMask);
1625         } else {
1626             globalEventMask |= ati->javaEventMask;
1627         }
1628         ati = ati->nextATInstance;
1629     }
1630     PrintDebugString("  union of all Java AT event masks: %X", globalEventMask);
1631     if (!(globalEventMask & type)) {
1632         // no other ATs wanted this event;
1633         // start getting them from Java
1634         PrintDebugString("  no other AT wanted this Java event (so not registered); adding to AccessBridge.java");
1635         windowsThreadEntryPoints->addJavaEventNotification(type);
1636     }
1637 }
1638 
1639 /**
1640  * removeJavaEventNotification - this AT no longer wants this type of events
1641  *
1642  */
1643 void
1644 JavaAccessBridge::removeJavaEventNotification(jlong type, HWND DLLwindow) {
1645     // walk through list of ATs, find this one and remove this type
1646     // and, if no other AT wants 'em either, tell Java we no longer want 'em
1647     PrintDebugString("  removing Java event type %016I64X from HWND %p", type, DLLwindow);
1648     AccessBridgeATInstance *ati = ATs;
1649     long globalEventMask = 0;
1650     while (ati != (AccessBridgeATInstance *) 0) {
1651         if (ati->winAccessBridgeWindow == DLLwindow) {
1652             ati->javaEventMask &= (0xFFFFFFFF - type);
1653             PrintDebugString("  found HWND, javaEventMask now is %X", ati->javaEventMask);
1654         } else {
1655             globalEventMask |= ati->javaEventMask;
1656         }
1657         ati = ati->nextATInstance;
1658     }
1659     PrintDebugString("  union of all Java AT event masks: %X", globalEventMask);
1660     if (!(globalEventMask & type)) {
1661         // no other ATs wanted this event;
1662         // stop getting them from Java
1663         PrintDebugString("  no other AT wanted this Java event (so can remove); removing from AccessBridge.java");
1664         windowsThreadEntryPoints->removeJavaEventNotification(type);
1665     }
1666 }
1667 
1668 
1669 /**
1670  * addAccesibilityEventNotification - this AT now wants this type of events
1671  *
1672  */
1673 void
1674 JavaAccessBridge::addAccessibilityEventNotification(jlong type, HWND DLLwindow) {
1675     // walk through list of ATs, find this one and add this type
1676     // and, if we weren't listening for these before, ask Java for 'em
1677     PrintDebugString("  adding Accesibility event type %016I64X to HWND %p", type, DLLwindow);
1678     AccessBridgeATInstance *ati = ATs;
1679     long globalEventMask = 0;
1680     while (ati != (AccessBridgeATInstance *) 0) {
1681         if (ati->winAccessBridgeWindow == DLLwindow) {
1682             ati->accessibilityEventMask |= type;
1683             PrintDebugString("  found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask);
1684         } else {
1685             globalEventMask |= ati->accessibilityEventMask;
1686         }
1687         ati = ati->nextATInstance;
1688     }
1689     PrintDebugString("  union of all Accessibility AT event masks: %X", globalEventMask);
1690     if (!(globalEventMask & type)) {
1691         // no other ATs wanted this event;
1692         // start getting them from Java
1693         PrintDebugString("  no other AT wanted this Accesibility event (so not registered); adding to AccessBridge.java");
1694         windowsThreadEntryPoints->addAccessibilityEventNotification(type);
1695     }
1696 }
1697 
1698 /**
1699  * removeAccesibilityEventNotification - this AT no longer wants this type of events
1700  *
1701  */
1702 void
1703 JavaAccessBridge::removeAccessibilityEventNotification(jlong type, HWND DLLwindow) {
1704     // walk through list of ATs, find this one and remove this type
1705     // and, if no other AT wants 'em either, tell Java we no longer want 'em
1706     PrintDebugString("  removing Accesibility event type %016I64X from HWND %p", type, DLLwindow);
1707     AccessBridgeATInstance *ati = ATs;
1708     long globalEventMask = 0;
1709     while (ati != (AccessBridgeATInstance *) 0) {
1710         if (ati->winAccessBridgeWindow == DLLwindow) {
1711             ati->accessibilityEventMask &= (0xFFFFFFFF - type);
1712             PrintDebugString("  found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask);
1713         } else {
1714             globalEventMask |= ati->accessibilityEventMask;
1715         }
1716         ati = ati->nextATInstance;
1717     }
1718     PrintDebugString("  union of all Accessibility AT event masks: %X", globalEventMask);
1719     if (!(globalEventMask & type)) {
1720         // no other ATs wanted this event;
1721         // stop getting them from Java
1722         PrintDebugString("  no other AT wanted this Accessibility event (so can remove); removing from AccessBridge.java");
1723         windowsThreadEntryPoints->removeAccessibilityEventNotification(type);
1724     }
1725 }
1726 
1727 
1728 
1729 
1730 /**
1731  * firePropertyCaretChange
1732  *
1733  */
1734 void
1735 JavaAccessBridge::firePropertyCaretChange(JNIEnv *env, jobject callingObj,
1736                                           jobject event, jobject source,
1737                                           jint oldValue, jint newValue) {
1738 
1739     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyCaretChanged(%p, %p, %p, %p, %d, %d)",
1740                      env, callingObj, event,
1741                      source, oldValue, newValue);
1742 
1743     // sanity check
1744     if (ATs == (AccessBridgeATInstance *) 0) {
1745         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1746         return;         // panic!
1747     }
1748 
1749     // common setup
1750     char buffer[sizeof(PackageType) + sizeof(PropertyCaretChangePackage)];
1751     PackageType *type = (PackageType *) buffer;
1752     PropertyCaretChangePackage *pkg = (PropertyCaretChangePackage *) (buffer + sizeof(PackageType));
1753     *type = cPropertyCaretChangePackage;
1754     pkg->vmID = (long) dialogWindow;
1755 
1756     // make new Global Refs and send events only to those ATs that want 'em
1757     AccessBridgeATInstance *ati = ATs;
1758     while (ati != (AccessBridgeATInstance *) 0) {
1759         if (ati->accessibilityEventMask & cPropertyCaretChangeEvent) {
1760 
1761             PrintDebugString("  sending to AT");
1762 
1763             // make new GlobalRefs for this AT
1764             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1765             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1766 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1767             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1768             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1769 #else // JOBJECT64 is jlong (64 bit)
1770             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1771             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1772 #endif
1773 
1774             pkg->oldPosition = oldValue;
1775             pkg->newPosition = newValue;
1776 
1777             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyCaretChangeEvent);
1778         }
1779         ati = ati->nextATInstance;
1780     }
1781     PrintDebugString("  done with propertyCaretChange event");
1782 }
1783 
1784 /**
1785  * firePropertyDescriptionChange
1786  *
1787  */
1788 void
1789 JavaAccessBridge::firePropertyDescriptionChange(JNIEnv *env, jobject callingObj,
1790                                                 jobject event, jobject source,
1791                                                 jstring oldValue, jstring newValue){
1792 
1793     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyDescriptionChanged(%p, %p, %p, %p, %p, %p)",
1794                      env, callingObj, event,
1795                      source, oldValue, newValue);
1796 
1797     // sanity check
1798     if (ATs == (AccessBridgeATInstance *) 0) {
1799         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1800         return;         // panic!
1801     }
1802 
1803     // common setup
1804     const wchar_t *stringBytes;
1805     char buffer[sizeof(PackageType) + sizeof(PropertyDescriptionChangePackage)];
1806     PackageType *type = (PackageType *) buffer;
1807     PropertyDescriptionChangePackage *pkg = (PropertyDescriptionChangePackage *) (buffer + sizeof(PackageType));
1808     *type = cPropertyDescriptionChangePackage;
1809     pkg->vmID = (long) dialogWindow;
1810 
1811     // make new Global Refs and send events only to those ATs that want 'em
1812     AccessBridgeATInstance *ati = ATs;
1813     while (ati != (AccessBridgeATInstance *) 0) {
1814         if (ati->accessibilityEventMask & cPropertyCaretChangeEvent) {
1815 
1816             PrintDebugString("  sending to AT");
1817 
1818             // make new GlobalRefs for this AT
1819             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1820             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1821 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1822             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1823             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1824 #else // JOBJECT64 is jlong (64 bit)
1825             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1826             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1827 #endif
1828 
1829             if (oldValue != (jstring) 0) {
1830                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
1831                 if (stringBytes == NULL) {
1832                     if (!env->ExceptionCheck()) {
1833                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1834                         if (cls != NULL) {
1835                             env->ThrowNew(cls, NULL);
1836                         }
1837                     }
1838                     return;
1839                 }
1840                 wcsncpy(pkg->oldDescription, stringBytes, (sizeof(pkg->oldDescription) / sizeof(wchar_t)));
1841                 env->ReleaseStringChars(oldValue, stringBytes);
1842             } else {
1843                 wcsncpy(pkg->oldDescription, L"(null)", (sizeof(pkg->oldDescription) / sizeof(wchar_t)));
1844             }
1845 
1846             if (newValue != (jstring) 0) {
1847                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
1848                 if (stringBytes == NULL) {
1849                    if (!env->ExceptionCheck()) {
1850                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1851                         if (cls != NULL) {
1852                             env->ThrowNew(cls, NULL);
1853                         }
1854                     }
1855                     return;
1856                 }
1857                 wcsncpy(pkg->newDescription, stringBytes, (sizeof(pkg->newDescription) / sizeof(wchar_t)));
1858                 env->ReleaseStringChars(newValue, stringBytes);
1859             } else {
1860                 wcsncpy(pkg->newDescription, L"(null)", (sizeof(pkg->newDescription) / sizeof(wchar_t)));
1861             }
1862 
1863             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyDescriptionChangeEvent);
1864         }
1865         ati = ati->nextATInstance;
1866     }
1867     PrintDebugString("  done with propertyDescriptionChange event");
1868 }
1869 
1870 /**
1871  * firePropertyNameChange
1872  *
1873  */
1874 void
1875 JavaAccessBridge::firePropertyNameChange(JNIEnv *env, jobject callingObj,
1876                                          jobject event, jobject source,
1877                                          jstring oldValue, jstring newValue){
1878 
1879     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyNameChanged(%p, %p, %p, %p, %p, %p)",
1880                      env, callingObj, event,
1881                      source, oldValue, newValue);
1882 
1883     // sanity check
1884     if (ATs == (AccessBridgeATInstance *) 0) {
1885         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1886         return;         // panic!
1887     }
1888 
1889     // common setup
1890     const wchar_t *stringBytes;
1891     char buffer[sizeof(PackageType) + sizeof(PropertyNameChangePackage)];
1892     PackageType *type = (PackageType *) buffer;
1893     PropertyNameChangePackage *pkg = (PropertyNameChangePackage *) (buffer + sizeof(PackageType));
1894     *type = cPropertyNameChangePackage;
1895     pkg->vmID = (long) dialogWindow;
1896 
1897     // make new Global Refs and send events only to those ATs that want 'em
1898     AccessBridgeATInstance *ati = ATs;
1899     while (ati != (AccessBridgeATInstance *) 0) {
1900         if (ati->accessibilityEventMask & cPropertyNameChangeEvent) {
1901 
1902             PrintDebugString("  sending to AT");
1903 
1904             // make new GlobalRefs for this AT
1905             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1906             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1907 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1908             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1909             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1910 #else // JOBJECT64 is jlong (64 bit)
1911             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1912             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1913 #endif
1914 
1915             if (oldValue != (jstring) 0) {
1916                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
1917                 if (stringBytes == NULL) {
1918                     if (!env->ExceptionCheck()) {
1919                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1920                         if (cls != NULL) {
1921                             env->ThrowNew(cls, NULL);
1922                         }
1923                     }
1924                     return;
1925                 }
1926                 wcsncpy(pkg->oldName, stringBytes, (sizeof(pkg->oldName) / sizeof(wchar_t)));
1927                 env->ReleaseStringChars(oldValue, stringBytes);
1928             } else {
1929                 wcsncpy(pkg->oldName, L"(null)", (sizeof(pkg->oldName) / sizeof(wchar_t)));
1930             }
1931 
1932             if (newValue != (jstring) 0) {
1933                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
1934                 if (stringBytes == NULL) {
1935                     if (!env->ExceptionCheck()) {
1936                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1937                         if (cls != NULL) {
1938                             env->ThrowNew(cls, NULL);
1939                         }
1940                     }
1941                     return;
1942                 }
1943                 wcsncpy(pkg->newName, stringBytes, (sizeof(pkg->newName) / sizeof(wchar_t)));
1944                 env->ReleaseStringChars(newValue, stringBytes);
1945             } else {
1946                 wcsncpy(pkg->newName, L"(null)", (sizeof(pkg->newName) / sizeof(wchar_t)));
1947             }
1948 
1949             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyNameChangeEvent);
1950         }
1951         ati = ati->nextATInstance;
1952     }
1953     PrintDebugString("  done with propertyNameChange event");
1954 }
1955 
1956 
1957 /**
1958  * firePropertySelectionChange
1959  *
1960  */
1961 void
1962 JavaAccessBridge::firePropertySelectionChange(JNIEnv *env, jobject callingObj,
1963                                               jobject event, jobject source) {
1964 
1965     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertySelectionChanged(%p, %p, %p, %p)",
1966                      env, callingObj, event, source);
1967 
1968     // sanity check
1969     if (ATs == (AccessBridgeATInstance *) 0) {
1970         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1971         return;         // panic!
1972     }
1973 
1974     // common setup
1975     char buffer[sizeof(PackageType) + sizeof(PropertySelectionChangePackage)];
1976     PackageType *type = (PackageType *) buffer;
1977     PropertySelectionChangePackage *pkg = (PropertySelectionChangePackage *) (buffer + sizeof(PackageType));
1978     *type = cPropertySelectionChangePackage;
1979     pkg->vmID = (long) dialogWindow;
1980 
1981     // make new Global Refs and send events only to those ATs that want 'em
1982     AccessBridgeATInstance *ati = ATs;
1983     while (ati != (AccessBridgeATInstance *) 0) {
1984         if (ati->accessibilityEventMask & cPropertySelectionChangeEvent) {
1985 
1986             PrintDebugString("  sending to AT");
1987 
1988             // make new GlobalRefs for this AT
1989             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1990             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1991 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1992             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1993             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1994 #else // JOBJECT64 is jlong (64 bit)
1995             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1996             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1997 #endif
1998 
1999             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertySelectionChangeEvent);
2000         }
2001         ati = ati->nextATInstance;
2002     }
2003     PrintDebugString("  done with propertySelectionChange event");
2004 }
2005 
2006 
2007 /**
2008  * firePropertyStateChange
2009  *
2010  */
2011 void
2012 JavaAccessBridge::firePropertyStateChange(JNIEnv *env, jobject callingObj,
2013                                           jobject event, jobject source,
2014                                           jstring oldValue, jstring newValue){
2015 
2016     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyStateChanged(%p, %p, %p, %p, %p, %p)",
2017                      env, callingObj, event,
2018                      source, oldValue, newValue);
2019 
2020     // sanity check
2021     if (ATs == (AccessBridgeATInstance *) 0) {
2022         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2023         return;         // panic!
2024     }
2025 
2026     // common setup
2027     const wchar_t *stringBytes;
2028     char buffer[sizeof(PackageType) + sizeof(PropertyStateChangePackage)];
2029     PackageType *type = (PackageType *) buffer;
2030     PropertyStateChangePackage *pkg = (PropertyStateChangePackage *) (buffer + sizeof(PackageType));
2031     *type = cPropertyStateChangePackage;
2032     pkg->vmID = (long) dialogWindow;
2033 
2034     // make new Global Refs and send events only to those ATs that want 'em
2035     AccessBridgeATInstance *ati = ATs;
2036     while (ati != (AccessBridgeATInstance *) 0) {
2037         if (ati->accessibilityEventMask & cPropertyStateChangeEvent) {
2038 
2039             PrintDebugString("  sending to AT");
2040 
2041             // make new GlobalRefs for this AT
2042             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2043             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2044 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2045             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2046             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2047 #else // JOBJECT64 is jlong (64 bit)
2048             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2049             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2050 #endif
2051 
2052             if (oldValue != (jstring) 0) {
2053                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
2054                 if (stringBytes == NULL) {
2055                     if (!env->ExceptionCheck()) {
2056                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2057                         if (cls != NULL) {
2058                             env->ThrowNew(cls, NULL);
2059                         }
2060                     }
2061                     return;
2062                 }
2063                 wcsncpy(pkg->oldState, stringBytes, (sizeof(pkg->oldState) / sizeof(wchar_t)));
2064                 env->ReleaseStringChars(oldValue, stringBytes);
2065             } else {
2066                 wcsncpy(pkg->oldState, L"(null)", (sizeof(pkg->oldState) / sizeof(wchar_t)));
2067             }
2068 
2069             if (newValue != (jstring) 0) {
2070                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
2071                 if (stringBytes == NULL) {
2072                     if (!env->ExceptionCheck()) {
2073                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2074                         if (cls != NULL) {
2075                             env->ThrowNew(cls, NULL);
2076                         }
2077                     }
2078                     return;
2079                 }
2080                 wcsncpy(pkg->newState, stringBytes, (sizeof(pkg->newState) / sizeof(wchar_t)));
2081                 env->ReleaseStringChars(newValue, stringBytes);
2082             } else {
2083                 wcsncpy(pkg->newState, L"(null)", (sizeof(pkg->newState) / sizeof(wchar_t)));
2084             }
2085 
2086             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyStateChangeEvent);
2087         }
2088         ati = ati->nextATInstance;
2089     }
2090     PrintDebugString("  done with propertyStateChange event");
2091 }
2092 
2093 
2094 /**
2095  * firePropertyTextChange
2096  *
2097  */
2098 void
2099 JavaAccessBridge::firePropertyTextChange(JNIEnv *env, jobject callingObj,
2100                                          jobject event, jobject source) {
2101 
2102     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyTextChanged(%p, %p, %p, %p)",
2103                      env, callingObj, event, source);
2104 
2105     // sanity check
2106     if (ATs == (AccessBridgeATInstance *) 0) {
2107         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2108         return;         // panic!
2109     }
2110 
2111     // common setup
2112     char buffer[sizeof(PackageType) + sizeof(PropertyTextChangePackage)];
2113     PackageType *type = (PackageType *) buffer;
2114     PropertyTextChangePackage *pkg = (PropertyTextChangePackage *) (buffer + sizeof(PackageType));
2115     *type = cPropertyTextChangePackage;
2116     pkg->vmID = (long) dialogWindow;
2117 
2118     // make new Global Refs and send events only to those ATs that want 'em
2119     AccessBridgeATInstance *ati = ATs;
2120     while (ati != (AccessBridgeATInstance *) 0) {
2121         if (ati->accessibilityEventMask & cPropertyTextChangeEvent) {
2122 
2123             PrintDebugString("  sending to AT");
2124 
2125             // make new GlobalRefs for this AT
2126             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2127             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2128 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2129             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2130             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2131 #else // JOBJECT64 is jlong (64 bit)
2132             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2133             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2134 #endif
2135 
2136             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyTextChangeEvent);
2137         }
2138         ati = ati->nextATInstance;
2139     }
2140     PrintDebugString("  done with propertyTextChange event");
2141 }
2142 
2143 
2144 /**
2145  * firePropertyValueChange
2146  *
2147  */
2148 void
2149 JavaAccessBridge::firePropertyValueChange(JNIEnv *env, jobject callingObj,
2150                                           jobject event, jobject source,
2151                                           jstring oldValue, jstring newValue){
2152 
2153     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyValueChanged(%p, %p, %p, %p, %p, %p)",
2154                      env, callingObj, event,
2155                      source, oldValue, newValue);
2156 
2157     // sanity check
2158     if (ATs == (AccessBridgeATInstance *) 0) {
2159         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2160         return;         // panic!
2161     }
2162 
2163     // common setup
2164     const wchar_t *stringBytes;
2165     char buffer[sizeof(PackageType) + sizeof(PropertyValueChangePackage)];
2166     PackageType *type = (PackageType *) buffer;
2167     PropertyValueChangePackage *pkg = (PropertyValueChangePackage *) (buffer + sizeof(PackageType));
2168     *type = cPropertyValueChangePackage;
2169     pkg->vmID = (long) dialogWindow;
2170 
2171     // make new Global Refs and send events only to those ATs that want 'em
2172     AccessBridgeATInstance *ati = ATs;
2173     while (ati != (AccessBridgeATInstance *) 0) {
2174         if (ati->accessibilityEventMask & cPropertyValueChangeEvent) {
2175 
2176             PrintDebugString("  sending to AT");
2177 
2178             // make new GlobalRefs for this AT
2179             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2180             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2181 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2182             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2183             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2184 #else // JOBJECT64 is jlong (64 bit)
2185             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2186             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2187 #endif
2188 
2189             if (oldValue != (jstring) 0) {
2190                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
2191                 if (stringBytes == NULL) {
2192                     if (!env->ExceptionCheck()) {
2193                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2194                         if (cls != NULL) {
2195                             env->ThrowNew(cls, NULL);
2196                         }
2197                     }
2198                     return;
2199                 }
2200                 wcsncpy(pkg->oldValue, stringBytes, (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2201                 env->ReleaseStringChars(oldValue, stringBytes);
2202             } else {
2203                 wcsncpy(pkg->oldValue, L"(null)", (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2204             }
2205 
2206             if (newValue != (jstring) 0) {
2207                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
2208                 if (stringBytes == NULL) {
2209                     if (!env->ExceptionCheck()) {
2210                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2211                         if (cls != NULL) {
2212                             env->ThrowNew(cls, NULL);
2213                         }
2214                     }
2215                     return;
2216                 }
2217                 wcsncpy(pkg->newValue, stringBytes, (sizeof(pkg->newValue) / sizeof(wchar_t)));
2218                 env->ReleaseStringChars(newValue, stringBytes);
2219             } else {
2220                 wcsncpy(pkg->newValue, L"(null)", (sizeof(pkg->newValue) / sizeof(wchar_t)));
2221             }
2222 
2223             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyValueChangeEvent);
2224         }
2225         ati = ati->nextATInstance;
2226     }
2227     PrintDebugString("  done with propertyValueChange event");
2228 }
2229 
2230 /**
2231  * firePropertyVisibleDataChange
2232  *
2233  */
2234 void
2235 JavaAccessBridge::firePropertyVisibleDataChange(JNIEnv *env, jobject callingObj,
2236                                                 jobject event, jobject source) {
2237 
2238     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyVisibleDataChanged(%p, %p, %p, %p)",
2239                      env, callingObj, event, source);
2240 
2241     // sanity check
2242     if (ATs == (AccessBridgeATInstance *) 0) {
2243         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2244         return;         // panic!
2245     }
2246 
2247     // common setup
2248     char buffer[sizeof(PackageType) + sizeof(PropertyVisibleDataChangePackage)];
2249     PackageType *type = (PackageType *) buffer;
2250     PropertyVisibleDataChangePackage *pkg = (PropertyVisibleDataChangePackage *) (buffer + sizeof(PackageType));
2251     *type = cPropertyVisibleDataChangePackage;
2252     pkg->vmID = (long) dialogWindow;
2253 
2254     // make new Global Refs and send events only to those ATs that want 'em
2255     AccessBridgeATInstance *ati = ATs;
2256     while (ati != (AccessBridgeATInstance *) 0) {
2257         if (ati->accessibilityEventMask & cPropertyVisibleDataChangeEvent) {
2258 
2259             PrintDebugString("  sending to AT");
2260 
2261             // make new GlobalRefs for this AT
2262             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2263             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2264 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2265             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2266             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2267 #else // JOBJECT64 is jlong (64 bit)
2268             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2269             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2270 #endif
2271 
2272             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyVisibleDataChangeEvent);
2273         }
2274         ati = ati->nextATInstance;
2275     }
2276     PrintDebugString("  done with propertyVisibleDataChange event");
2277 }
2278 
2279 
2280 /**
2281  * firePropertyChildChange
2282  *
2283  */
2284 void
2285 JavaAccessBridge::firePropertyChildChange(JNIEnv *env, jobject callingObj,
2286                                           jobject event, jobject source,
2287                                           jobject oldValue, jobject newValue){
2288 
2289     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyChildPropertyChanged(%p, %p, %p, %p, %p, %p)",
2290                      env, callingObj, event,
2291                      source, oldValue, newValue);
2292 
2293     // sanity check
2294     if (ATs == (AccessBridgeATInstance *) 0) {
2295         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2296         return;         // panic!
2297     }
2298 
2299     // common setup
2300     char buffer[sizeof(PackageType) + sizeof(PropertyChildChangePackage)];
2301     PackageType *type = (PackageType *) buffer;
2302     PropertyChildChangePackage *pkg = (PropertyChildChangePackage *) (buffer + sizeof(PackageType));
2303     *type = cPropertyChildChangePackage;
2304     pkg->vmID = (long) dialogWindow;
2305 
2306     // make new Global Refs and send events only to those ATs that want 'em
2307     AccessBridgeATInstance *ati = ATs;
2308     while (ati != (AccessBridgeATInstance *) 0) {
2309         if (ati->accessibilityEventMask & cPropertyChildChangeEvent) {
2310 
2311             PrintDebugString("  sending to AT");
2312 
2313             // make new GlobalRefs for this AT
2314             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2315             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2316             pkg->oldChildAccessibleContext = (JOBJECT64)env->NewGlobalRef(oldValue);
2317             pkg->newChildAccessibleContext = (JOBJECT64)env->NewGlobalRef(newValue);
2318 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2319             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2320             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2321             PrintDebugString("  GlobalRef'd OldChildAC: %p", pkg->oldChildAccessibleContext);
2322             PrintDebugString("  GlobalRef'd NewChildAC: %p", pkg->newChildAccessibleContext);
2323 #else // JOBJECT64 is jlong (64 bit)
2324             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2325             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2326             PrintDebugString("  GlobalRef'd OldChildAC: %016I64X", pkg->oldChildAccessibleContext);
2327             PrintDebugString("  GlobalRef'd NewChildAC: %016I64X", pkg->newChildAccessibleContext);
2328 #endif
2329 
2330             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyChildChangeEvent);
2331         }
2332         ati = ati->nextATInstance;
2333     }
2334     PrintDebugString("  done with propertyChildChange event");
2335 }
2336 
2337 
2338 /**
2339  * firePropertyActiveDescendentChange
2340  *
2341  */
2342 void
2343 JavaAccessBridge::firePropertyActiveDescendentChange(JNIEnv *env, jobject callingObj,
2344                                                      jobject event, jobject source,
2345                                                      jobject oldValue, jobject newValue){
2346 
2347     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyActiveDescendentPropertyChanged(%p, %p, %p, %p, %p, %p)",
2348                      env, callingObj, event,
2349                      source, oldValue, newValue);
2350 
2351     // sanity check
2352     if (ATs == (AccessBridgeATInstance *) 0) {
2353         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2354         return;         // panic!
2355     }
2356 
2357     // common setup
2358     char buffer[sizeof(PackageType) + sizeof(PropertyActiveDescendentChangePackage)];
2359     PackageType *type = (PackageType *) buffer;
2360     PropertyActiveDescendentChangePackage *pkg = (PropertyActiveDescendentChangePackage *) (buffer + sizeof(PackageType));
2361     *type = cPropertyActiveDescendentChangePackage;
2362     pkg->vmID = (long) dialogWindow;
2363 
2364     // make new Global Refs and send events only to those ATs that want 'em
2365     AccessBridgeATInstance *ati = ATs;
2366     while (ati != (AccessBridgeATInstance *) 0) {
2367         if (ati->accessibilityEventMask & cPropertyActiveDescendentChangeEvent) {
2368 
2369             PrintDebugString("  sending to AT");
2370 
2371             // make new GlobalRefs for this AT
2372             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2373             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2374             pkg->oldActiveDescendentAccessibleContext = (JOBJECT64)env->NewGlobalRef(oldValue);
2375             pkg->newActiveDescendentAccessibleContext = (JOBJECT64)env->NewGlobalRef(newValue);
2376 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2377             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2378             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2379             PrintDebugString("  GlobalRef'd OldActiveDescendentAC: %p", pkg->oldActiveDescendentAccessibleContext);
2380             PrintDebugString("  GlobalRef'd NewActiveDescendentAC: %p", pkg->newActiveDescendentAccessibleContext);
2381 #else // JOBJECT64 is jlong (64 bit)
2382             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2383             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2384             PrintDebugString("  GlobalRef'd OldActiveDescendentAC: %016I64X", pkg->oldActiveDescendentAccessibleContext);
2385             PrintDebugString("  GlobalRef'd NewActiveDescendentAC: %016I64X", pkg->newActiveDescendentAccessibleContext);
2386 #endif
2387 
2388             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyActiveDescendentChangeEvent);
2389         }
2390         ati = ati->nextATInstance;
2391     }
2392     PrintDebugString("  done with propertyActiveChange event");
2393 }
2394 
2395 /**
2396  * firePropertyValueChange
2397  *
2398  */
2399 void
2400 JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj,
2401                                                jobject event, jobject source,
2402                                                jstring oldValue, jstring newValue){
2403 
2404     PrintDebugString("\r\nJava_com_sun_java_accessibility_AccessBridge_propertyTableModelChange(%p, %p, %p, %p, %p, %p)",
2405                      env, callingObj, event,
2406                      source, oldValue, newValue);
2407 
2408     // sanity check
2409     if (ATs == (AccessBridgeATInstance *) 0) {
2410         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2411         return;         // panic!
2412     }
2413 
2414     // common setup
2415     const wchar_t *stringBytes;
2416     char buffer[sizeof(PackageType) + sizeof(PropertyTableModelChangePackage)];
2417     PackageType *type = (PackageType *) buffer;
2418     PropertyTableModelChangePackage *pkg = (PropertyTableModelChangePackage *) (buffer + sizeof(PackageType));
2419     *type = cPropertyTableModelChangePackage;
2420     pkg->vmID = (long) dialogWindow;
2421 
2422     // make new Global Refs and send events only to those ATs that want 'em
2423     AccessBridgeATInstance *ati = ATs;
2424     while (ati != (AccessBridgeATInstance *) 0) {
2425         if (ati->accessibilityEventMask & cPropertyTableModelChangeEvent) {
2426 
2427             PrintDebugString("  sending to AT");
2428 
2429             // make new GlobalRefs for this AT
2430             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2431             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2432 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2433             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2434             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2435 #else // JOBJECT64 is jlong (64 bit)
2436             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2437             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2438 #endif
2439 
2440             if (oldValue != (jstring) 0) {
2441                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
2442                 if (stringBytes == NULL) {
2443                     if (!env->ExceptionCheck()) {
2444                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2445                         if (cls != NULL) {
2446                             env->ThrowNew(cls, NULL);
2447                         }
2448                     }
2449                     return;
2450                 }
2451                 wcsncpy(pkg->oldValue, stringBytes, (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2452                 env->ReleaseStringChars(oldValue, stringBytes);
2453             } else {
2454                 wcsncpy(pkg->oldValue, L"(null)", (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2455             }
2456 
2457             if (newValue != (jstring) 0) {
2458                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
2459                 if (stringBytes == NULL) {
2460                     if (!env->ExceptionCheck()) {
2461                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2462                         if (cls != NULL) {
2463                             env->ThrowNew(cls, NULL);
2464                         }
2465                     }
2466                     return;
2467                 }
2468                 wcsncpy(pkg->newValue, stringBytes, (sizeof(pkg->newValue) / sizeof(wchar_t)));
2469                 env->ReleaseStringChars(newValue, stringBytes);
2470             } else {
2471                 wcsncpy(pkg->newValue, L"(null)", (sizeof(pkg->newValue) / sizeof(wchar_t)));
2472             }
2473 
2474             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyTableModelChangeEvent);
2475         }
2476         ati = ati->nextATInstance;
2477     }
2478     PrintDebugString("  done with propertyTableModelChange event");
2479 }
2480 
2481 
2482 
2483 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2484 #define PRINT_GLOBALREFS() \
2485     PrintDebugString("  GlobalRef'd Event: %p", pkg->Event); \
2486     PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2487 #else // JOBJECT64 is jlong (64 bit)
2488 #define PRINT_GLOBALREFS() \
2489     PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event); \
2490     PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2491 #endif
2492 
2493 #define FIRE_EVENT(function, packageStruct, packageConstant, eventConstant)             \
2494     void JavaAccessBridge::function(JNIEnv *env, jobject callingObj,                    \
2495                                     jobject eventObj, jobject source) {                 \
2496                                                                                         \
2497         PrintDebugString("\r\nFiring event id = %d(%p, %p, %p, %p); vmID = %X",         \
2498                          eventConstant, env, callingObj, eventObj, source, javaVM);     \
2499                                                                                         \
2500         /* sanity check */                                                              \
2501         if (ATs == (AccessBridgeATInstance *) 0) {                                      \
2502             PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");           \
2503             return;         /* panic! */                                                \
2504         }                                                                               \
2505                                                                                         \
2506         /* common setup */                                                              \
2507         char buffer[sizeof(PackageType) + sizeof(packageStruct)];                       \
2508         PackageType *type = (PackageType *) buffer;                                     \
2509         packageStruct *pkg = (packageStruct *) (buffer + sizeof(PackageType));          \
2510         *type = packageConstant;                                                        \
2511         pkg->vmID = (long) dialogWindow;                                                \
2512                                                                                         \
2513         /* make new Global Refs, send events only to those ATs that want 'em */         \
2514         AccessBridgeATInstance *ati = ATs;                                              \
2515         while (ati != (AccessBridgeATInstance *) 0) {                                   \
2516             PrintDebugString("\r\njavaEventMask = %X eventConstant=%d pkg->vmID=%X",    \
2517                              ati->javaEventMask, eventConstant, pkg->vmID );            \
2518             if (ati->javaEventMask & eventConstant) {                                   \
2519                                                                                         \
2520                 PrintDebugString("  sending to AT");                                    \
2521                 /* make new GlobalRefs for this AT */                                   \
2522                 pkg->Event = (JOBJECT64)env->NewGlobalRef(eventObj);                    \
2523                 pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);    \
2524                 PRINT_GLOBALREFS()                                                      \
2525                                                                                         \
2526                 ati->sendJavaEventPackage(buffer, sizeof(buffer), eventConstant);       \
2527             }                                                                           \
2528             ati = ati->nextATInstance;                                                  \
2529         }                                                                               \
2530         PrintDebugString("  done with firing AWT event");                               \
2531     }
2532 
2533     void JavaAccessBridge::javaShutdown(JNIEnv *env, jobject callingObj) {
2534 
2535         PrintDebugString("\r\nFiring event id = %d(%p, %p); vmID = %X",
2536                          cJavaShutdownEvent, env, callingObj, javaVM);
2537 
2538         /* sanity check */
2539         if (ATs == (AccessBridgeATInstance *) 0) {
2540             PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2541             return;             /* panic! */
2542         }
2543 
2544         /* common setup */
2545         char buffer[sizeof(PackageType) + sizeof(JavaShutdownPackage)];
2546         PackageType *type = (PackageType *) buffer;
2547         JavaShutdownPackage *pkg = (JavaShutdownPackage *) (buffer + sizeof(PackageType));
2548         *type = cJavaShutdownPackage;
2549         pkg->vmID = (long) dialogWindow;
2550 
2551         /* make new Global Refs, send events only to those ATs that want 'em */
2552         AccessBridgeATInstance *ati = ATs;
2553         while (ati != (AccessBridgeATInstance *) 0) {
2554             if (ati->javaEventMask & cJavaShutdownEvent) {
2555                 PrintDebugString("  sending to AT");
2556                 ati->sendJavaEventPackage(buffer, sizeof(buffer), cJavaShutdownEvent);
2557             }
2558             ati = ati->nextATInstance;
2559         }
2560         PrintDebugString("  done with firing AWT event");
2561     }
2562 
2563     FIRE_EVENT(fireFocusGained, FocusGainedPackage, cFocusGainedPackage, cFocusGainedEvent)
2564     FIRE_EVENT(fireFocusLost, FocusLostPackage, cFocusLostPackage, cFocusLostEvent)
2565     FIRE_EVENT(fireCaretUpdate, CaretUpdatePackage, cCaretUpdatePackage, cCaretUpdateEvent)
2566     FIRE_EVENT(fireMouseClicked, MouseClickedPackage, cMouseClickedPackage, cMouseClickedEvent)
2567     FIRE_EVENT(fireMouseEntered, MouseEnteredPackage, cMouseEnteredPackage, cMouseEnteredEvent)
2568     FIRE_EVENT(fireMouseExited, MouseExitedPackage, cMouseExitedPackage, cMouseExitedEvent)
2569     FIRE_EVENT(fireMousePressed, MousePressedPackage, cMousePressedPackage, cMousePressedEvent)
2570     FIRE_EVENT(fireMouseReleased, MouseReleasedPackage, cMouseReleasedPackage, cMouseReleasedEvent)
2571     FIRE_EVENT(fireMenuCanceled, MenuCanceledPackage, cMenuCanceledPackage, cMenuCanceledEvent)
2572     FIRE_EVENT(fireMenuDeselected, MenuDeselectedPackage, cMenuDeselectedPackage, cMenuDeselectedEvent)
2573     FIRE_EVENT(fireMenuSelected, MenuSelectedPackage, cMenuSelectedPackage, cMenuSelectedEvent)
2574     FIRE_EVENT(firePopupMenuCanceled, PopupMenuCanceledPackage, cPopupMenuCanceledPackage, cPopupMenuCanceledEvent)
2575     FIRE_EVENT(firePopupMenuWillBecomeInvisible, PopupMenuWillBecomeInvisiblePackage, cPopupMenuWillBecomeInvisiblePackage, cPopupMenuWillBecomeInvisibleEvent)
2576     FIRE_EVENT(firePopupMenuWillBecomeVisible, PopupMenuWillBecomeVisiblePackage, cPopupMenuWillBecomeVisiblePackage, cPopupMenuWillBecomeVisibleEvent)
2577 
2578 
2579     // -----------------------------
2580 
2581 
2582 extern "C" {        // event stuff from AccessBridge.h, generated by JNI
2583 
2584     JNIEXPORT void JNICALL
2585     Java_com_sun_java_accessibility_AccessBridge_sendDebugString(JNIEnv *env, jobject callingObj, jstring debugStr) {
2586 
2587         const wchar_t *stringBytes;
2588         stringBytes = (const wchar_t *) env->GetStringChars(debugStr, 0);
2589         if (stringBytes == NULL) {
2590             if (!env->ExceptionCheck()) {
2591                 jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2592                 if (cls != NULL) {
2593                     env->ThrowNew(cls, NULL);
2594                 }
2595             }
2596             return;
2597         }
2598         wPrintJavaDebugString(L"AccessBridge.java: %ls", stringBytes);
2599         env->ReleaseStringChars(debugStr, stringBytes);
2600     }
2601 
2602     JNIEXPORT void JNICALL
2603     Java_com_sun_java_accessibility_AccessBridge_propertyCaretChange(JNIEnv *env, jobject callingObj,
2604                                                                         jobject event, jobject source,
2605                                                                         jint oldValue, jint newValue) {
2606         theJavaAccessBridge->firePropertyCaretChange(env, callingObj,
2607                                                         event, source,
2608                                                         oldValue, newValue);
2609     }
2610 
2611     JNIEXPORT void JNICALL
2612     Java_com_sun_java_accessibility_AccessBridge_propertyDescriptionChange(JNIEnv *env, jobject callingObj,
2613                                                                             jobject event, jobject source,
2614                                                                             jstring oldValue, jstring newValue) {
2615         theJavaAccessBridge->firePropertyDescriptionChange(env, callingObj,
2616                                                             event, source,
2617                                                             oldValue, newValue);
2618     }
2619 
2620     JNIEXPORT void JNICALL
2621     Java_com_sun_java_accessibility_AccessBridge_propertyNameChange(JNIEnv *env, jobject callingObj,
2622                                                                     jobject event, jobject source,
2623                                                                     jstring oldValue, jstring newValue) {
2624         theJavaAccessBridge->firePropertyNameChange(env, callingObj,
2625                                                     event, source,
2626                                                     oldValue, newValue);
2627     }
2628 
2629     JNIEXPORT void JNICALL
2630     Java_com_sun_java_accessibility_AccessBridge_propertySelectionChange(JNIEnv *env, jobject callingObj,
2631                                                                             jobject event, jobject source) {
2632         theJavaAccessBridge->firePropertySelectionChange(env, callingObj,
2633                                                             event, source);
2634     }
2635 
2636     JNIEXPORT void JNICALL
2637     Java_com_sun_java_accessibility_AccessBridge_propertyStateChange(JNIEnv *env, jobject callingObj,
2638                                                                         jobject event, jobject source,
2639                                                                         jstring oldValue, jstring newValue) {
2640         theJavaAccessBridge->firePropertyStateChange(env, callingObj,
2641                                                         event, source,
2642                                                         oldValue, newValue);
2643     }
2644 
2645     JNIEXPORT void JNICALL
2646     Java_com_sun_java_accessibility_AccessBridge_propertyTextChange(JNIEnv *env, jobject callingObj,
2647                                                                     jobject event,  jobject source) {
2648         theJavaAccessBridge->firePropertyTextChange(env, callingObj,
2649                                                     event, source);
2650     }
2651 
2652     JNIEXPORT void JNICALL
2653     Java_com_sun_java_accessibility_AccessBridge_propertyValueChange(JNIEnv *env, jobject callingObj,
2654                                                                         jobject event, jobject source,
2655                                                                         jstring oldValue, jstring newValue) {
2656         theJavaAccessBridge->firePropertyValueChange(env, callingObj,
2657                                                         event, source,
2658                                                         oldValue, newValue);
2659     }
2660 
2661     JNIEXPORT void JNICALL
2662     Java_com_sun_java_accessibility_AccessBridge_propertyVisibleDataChange(JNIEnv *env, jobject callingObj,
2663                                                                             jobject event,  jobject source) {
2664         theJavaAccessBridge->firePropertyVisibleDataChange(env, callingObj,
2665                                                             event, source);
2666     }
2667 
2668     JNIEXPORT void JNICALL
2669     Java_com_sun_java_accessibility_AccessBridge_propertyChildChange(JNIEnv *env, jobject callingObj,
2670                                                                         jobject event, jobject source,
2671                                                                         jobject oldValue, jobject newValue) {
2672         theJavaAccessBridge->firePropertyChildChange(env, callingObj,
2673                                                         event, source,
2674                                                         oldValue, newValue);
2675     }
2676 
2677     JNIEXPORT void JNICALL
2678     Java_com_sun_java_accessibility_AccessBridge_propertyActiveDescendentChange(JNIEnv *env, jobject callingObj,
2679                                                                                 jobject event,  jobject source,
2680                                                                                 jobject oldValue,
2681                                                                                 jobject newValue) {
2682         theJavaAccessBridge->firePropertyActiveDescendentChange(env, callingObj,
2683                                                                 event, source,
2684                                                                 oldValue, newValue);
2685     }
2686 
2687     JNIEXPORT void JNICALL
2688     Java_com_sun_java_accessibility_AccessBridge_propertyTableModelChange(JNIEnv *env, jobject callingObj,
2689                                                                             jobject event,  jobject source,
2690                                                                             jstring oldValue, jstring newValue) {
2691 
2692         theJavaAccessBridge->firePropertyTableModelChange(env, callingObj,
2693                                                             event, source,
2694                                                             oldValue, newValue);
2695     }
2696 
2697 #define HANDLE_STANDARD_EVENT_FROM_JAVA(function, method) \
2698     JNIEXPORT void JNICALL \
2699     function(JNIEnv *env, jobject callingObj, jobject event, jobject source) { \
2700         theJavaAccessBridge->method(env, callingObj, event, source); \
2701     }
2702 
2703 
2704     JNIEXPORT void JNICALL
2705     Java_com_sun_java_accessibility_AccessBridge_javaShutdown(JNIEnv *env, jobject callingObj) {
2706         theJavaAccessBridge->javaShutdown(env, callingObj);
2707     }
2708 
2709     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_focusGained, fireFocusGained)
2710     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_focusLost, fireFocusLost)
2711     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_caretUpdate, fireCaretUpdate)
2712     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseClicked, fireMouseClicked)
2713     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseEntered, fireMouseEntered)
2714     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseExited, fireMouseExited)
2715     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mousePressed, fireMousePressed)
2716     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_mouseReleased, fireMouseReleased)
2717     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_menuCanceled, fireMenuCanceled)
2718     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_menuDeselected, fireMenuDeselected)
2719     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_menuSelected, fireMenuSelected)
2720     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_popupMenuCanceled, firePopupMenuCanceled)
2721     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_popupMenuWillBecomeInvisible, firePopupMenuWillBecomeInvisible)
2722     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_AccessBridge_popupMenuWillBecomeVisible, firePopupMenuWillBecomeVisible)
2723 
2724     }