[orca] Fix for bgo#581532 - Remove brl module



commit ea1d9d3a2491534d28596c99328e92a90187bffe
Author: Willie Walker <william walker sun com>
Date:   Mon May 4 14:44:00 2009 -0400

    Fix for bgo#581532 - Remove brl module
---
 configure.in        |   21 +---
 src/Makefile.am     |    4 +-
 src/brl/.cvsignore  |    2 -
 src/brl/.gitignore  |    6 -
 src/brl/Makefile.am |   17 --
 src/brl/brlmodule.c |  410 ---------------------------------------------------
 src/orca/braille.py |  327 ++++++++++++-----------------------------
 src/orca/default.py |   16 +-
 8 files changed, 105 insertions(+), 698 deletions(-)

diff --git a/configure.in b/configure.in
index 4d0aebf..07c88ed 100644
--- a/configure.in
+++ b/configure.in
@@ -62,11 +62,6 @@ AM_PROG_LIBTOOL
 #	gnome-speech-1.0 >= 0.3.10 \
 #)
 
-# Setup brl module build
-#
-PKG_CHECK_MODULES(brl, \
-	glib-2.0 >= 2.10.0)
-
 # Find the idl compiler
 
 ORBIT_IDL=`pkg-config --variable=orbit_idl ORBit-2.0`
@@ -120,18 +115,7 @@ AM_CHECK_PYORBIT_MOD(Accessibility,,[AC_MSG_ERROR(Could not find python ORBit mo
 AM_CHECK_PYORBIT_MOD(GNOME_Speech,,[AC_MSG_WARN(Could not find python ORBit module Speech - you need gnome-speech-1.0 >= 0.3.10 installed to use speech)])
 AM_CHECK_PYORBIT_MOD(GNOME_Magnifier,,[AC_MSG_WARN(Could not find python ORBit module GNOME_Magnifier - you need gnome-mag-1.0 >= 0.12.5 installed to use magnification)])
 
-# Check for BrlAPI.  For BrlTTY <= v3.7.2, there were no Python bindings
-# for BrlAPI, so we rolled our own.  We know if we have v3.7.2 installed
-# because brlapi_initializeConnection will exist, whereas it was removed
-# from later versions.  For later versions (3.8 and up), BrlAPI provides
-# Python bindings in the 'brlapi' module, so we check for that as well.
-# Orca's braille.py module attempts to automatically find and use the 
-# right one at run time.
-#
-AC_CHECK_LIB(brlapi, brlapi_initializeConnection,[brlapi_available="yes"],[brlapi_available="no"])
-if test "x$brlapi_available" = "xno" ; then
-    AM_CHECK_PYMOD(brlapi,,[brlapi_available="yes"],[brlapi_available="no"])
-fi
+AM_CHECK_PYMOD(brlapi,,[brlapi_available="yes"],[brlapi_available="no"])
 
 AC_ARG_ENABLE(liblouis, 
               AC_HELP_STRING([--enable-liblouis=@<:@no/yes/auto@:>@],
@@ -173,7 +157,6 @@ docs/man/Makefile
 po/Makefile.in
 icons/Makefile
 src/Makefile
-src/brl/Makefile
 src/louis/Makefile
 src/louis/constants.py
 src/orca/Makefile
@@ -198,7 +181,7 @@ src/orca/platform.py
 
 if test "x$brlapi_available" = "xno" ; then
 echo
-echo "NOTE: Braille support requires BrlTTY >= 3.7.2 and BrlAPI >= 0.4.1."
+echo "NOTE: Braille support requires BrlTTY >= 3.9 and BrlAPI >= 0.5.1."
 echo "A suitable version could not be found, so braille will not be enabled."
 echo
 fi
diff --git a/src/Makefile.am b/src/Makefile.am
index a1b7916..1c417c6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
 if WITH_LOUIS
-SUBDIRS = brl orca louis
+SUBDIRS = orca louis
 else
-SUBDIRS = brl orca
+SUBDIRS = orca
 endif
\ No newline at end of file
diff --git a/src/brl/.cvsignore b/src/brl/.cvsignore
deleted file mode 100644
index 282522d..0000000
--- a/src/brl/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/src/brl/.gitignore b/src/brl/.gitignore
deleted file mode 100644
index e9793ab..0000000
--- a/src/brl/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-Makefile
-Makefile.in
-.libs
-.deps
-*.la
-*.lo
diff --git a/src/brl/Makefile.am b/src/brl/Makefile.am
deleted file mode 100644
index a9fdb1c..0000000
--- a/src/brl/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-module_LTLIBRARIES = brlmodule.la
-
-moduledir = $(pyexecdir)/orca
-
-brlmodule_la_LIBADD = \
-	$(brl_LIBS)
-
-brlmodule_la_CFLAGS = \
-	$(brl_CFLAGS) \
-	$(PYTHON_INCLUDES)
-
-brlmodule_la_LDFLAGS = \
-	-module \
-	-avoid-version
-
-brlmodule_la_SOURCES = \
-	brlmodule.c
diff --git a/src/brl/brlmodule.c b/src/brl/brlmodule.c
deleted file mode 100644
index fb80c27..0000000
--- a/src/brl/brlmodule.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Orca
- *
- * Copyright 2004-2008 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., Franklin Street, Fifth Floor,
- * Boston MA  02110-1301 USA.
- *
- */
-#include <string.h>
-#include <errno.h>
-#include <dlfcn.h>
-#include <glib.h>
-#include <Python.h>
-
-
-/* BrlAPI function pointers - these map directly to BrlAPI 3.6.2 methods.
- */
-static int (*brlapi_initializeConnection)(const void *clientSettings,
-                                          const void *usedSettings);
-static void (*brlapi_closeConnection)(void);
-
-static int (*brlapi_getDriverId)(unsigned char *id, unsigned int n);
-static int (*brlapi_getDriverName)(unsigned char *name, unsigned int n);
-static int (*brlapi_getDisplaySize)(unsigned int *x, unsigned int *y);
-
-static int (*brlapi_getTty) (int tty, int how);
-static int (*brlapi_leaveTty) (void);
-
-static int (*brlapi_writeText) (int cursor, const unsigned char *str);
-static int (*brlapi_writeDots) (const unsigned char *dots);
-
-static int (*brlapi_readKey) (int block, unsigned int *code);
-
-/* A non-zero value indicates this module has been initialized and is
- * ready for communication with BrlTTY.
- */
-static long brl_initialized = 0;
-
-/* Python callback for Braille command notifications.  Only ONE callback can
- * be registered at a time.
- */
-static PyObject *brl_callback = NULL;
-
-/* The g_io_add_watch (see glib docs) that keeps track of input events
- * coming from BrlTTY.
- */
-static gboolean brlapi_io_cb(GIOChannel *ch,
-                             GIOCondition condition,
-                             void *data) {
-
-        unsigned int keypress;
-        PyObject *result;
-        PyObject *args;
-        PyGILState_STATE gstate;
-
-        while (brlapi_readKey(0, &keypress) == 1) {
-                if (!brl_callback) {
-                        break;
-                }
-                args = Py_BuildValue("(i)", keypress);
-                gstate = PyGILState_Ensure();
-                result = PyObject_CallObject(brl_callback, args);
-                if (result != NULL) {
-                        Py_DECREF(result);
-                } else {
-                        PyErr_Print();
-                }
-                PyGILState_Release(gstate);
-                Py_DECREF(args);
-        }
-        return TRUE;
-}
-
-
-/* Initializes the brl module, connecting to BrlTTY.  Returns 0 on failure or
- * 1 on success.  The first argument is optional and indicated the tty to
- * open.  The default value for this argument is -1, which means to let BrlTTY
- * use its default logic.  A typical value might be 7 which is usually what
- * the CONTROLVT should be set to for a console running the X11 server.  The
- * second argument is also optional and is to be passed to brlapi_getTty and
- * is used to tell BrlTTY whether to return raw keycodes (BRLKEYCODES=1) or
- * BrlTTY commands (BRLCOMMANDS=0).  The default value is to give us
- * BRLCOMMANDS.
- */
-static PyObject *brl_module_init(PyObject *self,
-                                 PyObject *args) {
-        int tty = -1;
-        int how = 0;  /* BRLCOMMANDS */
-        int ttyNum;
-
-        void *brlapi_library;
-        int brlapi_fd;
-        GIOChannel *brlapi_channel;
-
-        if (brl_initialized) {
-                PyErr_SetString(PyExc_StandardError, "Already initialized");
-                return NULL;
-        }
-
-        if (!PyArg_ParseTuple (args, "|ii:init", &tty, &how))
-                return NULL;
-
-        /* Open the brlapi library
-         */
-        brlapi_library = dlopen("libbrlapi.so", RTLD_LAZY);
-        if (!brlapi_library) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to load libbrlapi.so");
-                return NULL;
-        }
-
-        /* Load the functions */
-
-        brlapi_initializeConnection =
-                (int (*)(const void *, const void *)) dlsym(brlapi_library,
-                                            "brlapi_initializeConnection");
-        if (!brlapi_initializeConnection) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_initializeConnection in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_closeConnection =
-                (void (*)(void)) dlsym(brlapi_library,
-                                       "brlapi_closeConnection");
-        if (!brlapi_closeConnection) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_closeConnection in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_getDriverId =
-                (int (*)(unsigned char *, unsigned int)) dlsym(brlapi_library,
-                                                        "brlapi_getDriverId");
-        if (!brlapi_getDriverId) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_getDriverId in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_getDriverName =
-                (int (*)(unsigned char *, unsigned int)) dlsym(brlapi_library,
-                                                       "brlapi_getDriverName");
-        if (!brlapi_getDriverName) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_getDriverName in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_getDisplaySize =
-                (int (*)(unsigned int *, unsigned int *)) dlsym(brlapi_library,
-                                                      "brlapi_getDisplaySize");
-        if (!brlapi_getDisplaySize) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_getDisplaySize in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_getTty =
-                (int (*) (int tty, int how)) dlsym(brlapi_library,
-                                                   "brlapi_getTty");
-        if (!brlapi_getTty) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_getTty in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_leaveTty =
-                (int (*) (void)) dlsym(brlapi_library,
-                                       "brlapi_leaveTty");
-        if (!brlapi_leaveTty) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_leaveTty in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_writeText =
-                (int (*) (int, const unsigned char *)) dlsym(brlapi_library,
-                                                         "brlapi_writeText");
-        if (!brlapi_writeText) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_writeText in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_writeDots =
-                (int (*) (const unsigned char *)) dlsym(brlapi_library,
-                                                        "brlapi_writeDots");
-        if (!brlapi_writeDots) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_writeDots in BrlTTY");
-                return NULL;
-        }
-
-        brlapi_readKey =
-                (int (*) (int, unsigned int *)) dlsym(brlapi_library,
-                                                      "brlapi_readKey");
-        if (!brlapi_readKey) {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed to find brlapi_readKey in BrlTTY");
-                return NULL;
-        }
-
-        /* Connect to BrlTTY
-         */
-        brlapi_fd = brlapi_initializeConnection(NULL, NULL);
-        if (brlapi_fd >= 0) {
-                /* Take over the owning tty.
-                 */
-                ttyNum = brlapi_getTty(tty,
-                                       0); /* HOW = give me BRLCOMMANDS */
-                if (ttyNum == -1) {
-                        PyErr_SetString(
-                                PyExc_StandardError,
-                                "Failed on call to brlapi_getTty in BrlTTY");
-                        return NULL;
-                }
-
-                /* Setup the GIOChannel to receive notifications of Braille
-                 * key events
-                 */
-                brlapi_channel = g_io_channel_unix_new(brlapi_fd);
-                g_io_add_watch(brlapi_channel,
-                               G_IO_IN,
-                               brlapi_io_cb,
-                               NULL);
-                brl_initialized = 1;
-                return PyInt_FromLong(brl_initialized);
-        } else {
-                PyErr_SetString(
-                        PyExc_StandardError,
-                        "Failed on call to brlapi_initializeConnection in BrlTTY");
-                return NULL;
-        }
-}
-
-
-static PyObject *brl_module_shutdown(PyObject *self) {
-        if (brl_initialized) {
-                /* [[[TODO: WDW - clean up the g_io_channel here?  Logged
-                 * as bugzilla bug 319649.]]]
-                 */
-                brlapi_leaveTty();
-                brlapi_closeConnection();
-        }
-        brl_initialized = 0;
-        return PyInt_FromLong(1);
-}
-
-
-static PyObject *brl_module_getDriverId (PyObject *self) {
-        unsigned char id[3];
-
-        if (!brl_initialized) {
-                Py_INCREF (Py_None);
-                return Py_None;
-        }
-
-        if (brlapi_getDriverId(id, sizeof(id)) >= 0) {
-                return PyString_FromString((const char *) id);
-        } else {
-                Py_INCREF (Py_None);
-                return Py_None;
-        }
-
-	return Py_None;
-}
-
-
-static PyObject *brl_module_getDriverName(PyObject *self) {
-        unsigned char name[80];
-
-        if (!brl_initialized) {
-                Py_INCREF(Py_None);
-                return Py_None;
-        }
-
-        if (brlapi_getDriverName(name, sizeof(name)) >= 0) {
-                return PyString_FromString((const char *) name);
-        } else {
-                Py_INCREF (Py_None);
-                return Py_None;
-        }
-
-	return Py_None;
-}
-
-
-static PyObject *brl_module_getDisplayWidth(PyObject *self) {
-        unsigned int x, y;
-
-        if (!brl_initialized) {
-                return PyInt_FromLong(0);
-        }
-
-        brlapi_getDisplaySize(&x, &y);
-        return PyInt_FromLong(x);
-}
-
-
-static PyObject *brl_module_getDisplayHeight(PyObject *self) {
-        unsigned int x, y;
-
-        if (!brl_initialized) {
-                return PyInt_FromLong(0);
-        }
-
-        brlapi_getDisplaySize(&x, &y);
-        return PyInt_FromLong(y);
-}
-
-
-static PyObject *brl_module_writeText(PyObject *self,
-                                      PyObject *args) {
-        int cursor;
-        char *str;
-
-        if (!PyArg_ParseTuple(args, "is:writeText", &cursor, &str)) {
-                return NULL;
-        }
-
-        if (brl_initialized) {
-            brlapi_writeText(cursor, (const unsigned char *) str);
-        }
-
-        Py_INCREF(Py_None);
-        return Py_None;
-}
-
-
-static PyObject *brl_module_writeDots(PyObject *self,
-                                      PyObject *args) {
-        char *str;
-
-        if (!PyArg_ParseTuple(args, "s:writeText", &str)) {
-                return NULL;
-        }
-
-        if (brl_initialized) {
-            brlapi_writeDots((const unsigned char *) str);
-        }
-        Py_INCREF(Py_None);
-        return Py_None;
-}
-
-
-static PyObject *brl_module_registerCallback(PyObject *self,
-                                             PyObject *args) {
-        if (brl_callback) {
-                Py_DECREF (brl_callback);
-        }
-        if (brl_initialized) {
-                brl_callback = PyTuple_GetItem(args, 0);
-                Py_INCREF(brl_callback);
-        }
-        Py_INCREF(Py_None);
-        return Py_None;
-}
-
-
-static PyObject *brl_module_unregisterCallback(PyObject *self) {
-        if (brl_callback)
-                Py_DECREF(brl_callback);
-        brl_callback = NULL;
-        Py_INCREF(Py_None);
-        return Py_None;
-}
-
-
-static PyMethodDef brl_methods[] = {
-        {"init", (PyCFunction) brl_module_init, METH_VARARGS},
-        {"shutdown", (PyCFunction) brl_module_shutdown, METH_NOARGS},
-        {"getDriverId", (PyCFunction) brl_module_getDriverId, METH_NOARGS},
-        {"getDriverName", (PyCFunction) brl_module_getDriverName, METH_NOARGS},
-        {"getDisplayWidth", (PyCFunction) brl_module_getDisplayWidth, METH_NOARGS},
-        {"getDisplayHeight", (PyCFunction) brl_module_getDisplayWidth, METH_NOARGS},
-        {"writeText", (PyCFunction) brl_module_writeText, METH_VARARGS},
-        {"writeDots", (PyCFunction) brl_module_writeDots, METH_VARARGS},
-        {"registerCallback", (PyCFunction) brl_module_registerCallback, METH_VARARGS},
-        {"unregisterCallback", (PyCFunction) brl_module_unregisterCallback, METH_NOARGS},
-        {NULL, NULL}
-};
-
-void initbrl (void) {
-        (void) Py_InitModule ("brl", brl_methods);
-}
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 122cf9b..ae9e475 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -44,21 +44,15 @@ except ImportError:
 else:
     _defaultContractionTable = louis.getDefaultTable()
 
-# We'll use the official BrlAPI pythons (as of BrlTTY 3.8) if they
-# are available.  Otherwise, we'll fall back to our own bindings.
-#
 try:
     import brlapi
     import gobject
 
-    brlAPI = None
-    useBrlAPIBindings = True
-    brlAPIRunning = False
-    brlAPISourceId = 0
+    _brlAPI = None
+    _brlAPIRunning = False
+    _brlAPISourceId = 0
 except:
-    import brl
-    useBrlAPIBindings = False
-    brlAPIRunning = False
+    _brlAPIRunning = False
 
 try:
     # This can fail due to gtk not being available.  We want to
@@ -84,79 +78,6 @@ _initialized = False
 #
 monitor = None
 
-# Each of these maps to BrlAPI's brldefs.h file.
-#
-CMD_NOOP              = 0x00
-CMD_LNUP              = 0x01
-CMD_LNDN              = 0x02
-CMD_WINUP             = 0x03
-CMD_WINDN             = 0x04
-CMD_PRDIFLN           = 0x05
-CMD_NXDIFLN           = 0x06
-CMD_ATTRUP            = 0x07
-CMD_ATTRDN            = 0x08
-CMD_TOP               = 0x09
-CMD_BOT               = 0x0a
-CMD_TOP_LEFT          = 0x0b
-CMD_BOT_LEFT          = 0x0c
-CMD_PRPGRPH           = 0x0d
-CMD_NXPGRPH           = 0x0e
-CMD_PRPROMPT          = 0x0f
-CMD_NXPROMPT          = 0x10
-CMD_PRSEARCH          = 0x11
-CMD_NXSEARCH          = 0x12
-CMD_CHRLT             = 0x13
-CMD_CHRRT             = 0x14
-CMD_HWINLT            = 0x15
-CMD_HWINRT            = 0x16
-CMD_FWINLT            = 0x17
-CMD_FWINRT            = 0x18
-CMD_FWINLTSKIP        = 0x19
-CMD_FWINRTSKIP        = 0x1a
-CMD_LNBEG             = 0x1b
-CMD_LNEND             = 0x1c
-CMD_HOME              = 0x1d
-CMD_BACK              = 0x1e
-CMD_FREEZE            = 0x1f
-CMD_DISPMD            = 0x20
-CMD_SIXDOTS           = 0x21
-CMD_SLIDEWIN          = 0x22
-CMD_SKPIDLNS          = 0x23
-CMD_SKPBLNKWINS       = 0x24
-CMD_CSRVIS            = 0x25
-CMD_CSRHIDE           = 0x26
-CMD_CSRTRK            = 0x27
-CMD_CSRSIZE           = 0x28
-CMD_CSRBLINK          = 0x29
-CMD_ATTRVIS           = 0x2a
-CMD_ATTRBLINK         = 0x2b
-CMD_CAPBLINK          = 0x2c
-CMD_TUNES             = 0x2d
-CMD_HELP              = 0x2e
-CMD_INFO              = 0x2f
-CMD_LEARN             = 0x30
-CMD_PREFMENU          = 0x31
-CMD_PREFSAVE          = 0x32
-CMD_PREFLOAD          = 0x33
-CMD_MENU_FIRST_ITEM   = 0x34
-CMD_MENU_LAST_ITEM    = 0x35
-CMD_MENU_PREV_ITEM    = 0x36
-CMD_MENU_NEXT_ITEM    = 0x37
-CMD_MENU_PREV_SETTING = 0x38
-CMD_MENU_NEXT_SETTING = 0x39
-CMD_SAY_LINE          = 0x3a
-CMD_SAY_ABOVE         = 0x3b
-CMD_SAY_BELOW         = 0x3c
-CMD_MUTE              = 0x3d
-CMD_SPKHOME           = 0x3e
-CMD_SWITCHVT_PREV     = 0x3f
-CMD_SWITCHVT_NEXT     = 0x40
-CMD_CSRJMP_VERT       = 0x41
-CMD_PASTE             = 0x42
-CMD_RESTARTBRL        = 0x43
-CMD_RESTARTSPEECH     = 0x44
-CMD_MAX               = 0x44
-
 BRL_FLG_REPEAT_INITIAL = 0x800000
 BRL_FLG_REPEAT_DELAY   = 0x400000
 
@@ -169,52 +90,52 @@ command_name = {}
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls to the left.
 #
-command_name[CMD_FWINLT]   = _("Line Left")
+command_name[brlapi.KEY_CMD_FWINLT]   = _("Line Left")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls to the right.
 #
-command_name[CMD_FWINRT]   = _("Line Right")
+command_name[brlapi.KEY_CMD_FWINRT]   = _("Line Right")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls up.
 #
-command_name[CMD_LNUP]     = _("Line Up")
+command_name[brlapi.KEY_CMD_LNUP]     = _("Line Up")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls down.
 #
-command_name[CMD_LNDN]     = _("Line Down")
+command_name[brlapi.KEY_CMD_LNDN]     = _("Line Down")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, it instructs the braille display to freeze.
 #
-command_name[CMD_FREEZE]     = _("Freeze")
+command_name[brlapi.KEY_CMD_FREEZE]     = _("Freeze")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls to the top left of the
 # window.
 #
-command_name[CMD_TOP_LEFT] = _("Top Left")
+command_name[brlapi.KEY_CMD_TOP_LEFT] = _("Top Left")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls to the bottom right of
 # the window.
 #
-command_name[CMD_BOT_LEFT] = _("Bottom Right")
+command_name[brlapi.KEY_CMD_BOT_LEFT] = _("Bottom Right")
 
 # Translators: this is a command for a button on a refreshable braille
 # display (an external hardware device used by people who are blind).
 # When pressing the button, the display scrolls to position containing
 # the cursor.
 #
-command_name[CMD_HOME]     = _("Cursor Position")
+command_name[brlapi.KEY_CMD_HOME]     = _("Cursor Position")
 
 # The size of the physical display (width, height).  The coordinate system of
 # the display is set such that the upper left is (0,0), x values increase from
@@ -986,11 +907,8 @@ def refresh(panToCursor=True, targetCursorCell=0, getLinkMask=True):
     global monitor
 
     if len(_lines) == 0:
-        if useBrlAPIBindings:
-            if brlAPIRunning:
-                brlAPI.writeText("", 0)
-        else:
-            brl.writeText(0, "")
+        if _brlAPIRunning:
+            _brlAPI.writeText("", 0)
         return
 
     # Now determine the location of the cursor.  First, we'll figure
@@ -1046,40 +964,37 @@ def refresh(panToCursor=True, targetCursorCell=0, getLinkMask=True):
     log.info(logLine.encode("UTF-8"))
 
     substring = string[startPos:endPos]
-    if useBrlAPIBindings:
-        if brlAPIRunning:
-            writeStruct = brlapi.WriteStruct()
-            writeStruct.regionBegin = 1
-            writeStruct.regionSize = len(substring)
-            while writeStruct.regionSize < _displaySize[0]:
-                substring += " "
-                if attributeMask:
-                    attributeMask += '\x00'
-                writeStruct.regionSize += 1
-            writeStruct.text = substring
-            writeStruct.cursor = cursorCell
-
-            # [[[WDW - if you want to muck around with the dots on the
-            # display to do things such as add underlines, you can use
-            # the attrOr field of the write structure to do so.  The
-            # attrOr field is a string whose length must be the same
-            # length as the display and whose dots will end up showing
-            # up on the display.  Each character represents a bitfield
-            # where each bit corresponds to a dot (i.e., bit 0 = dot 1,
-            # bit 1 = dot 2, and so on).  Here's an example that underlines
-            # all the text.]]]
-            #
-            #myUnderline = ""
-            #for i in range(0, _displaySize[0]):
-            #    myUnderline += '\xc0'
-            #writeStruct.attrOr = myUnderline
-
+    if _brlAPIRunning:
+        writeStruct = brlapi.WriteStruct()
+        writeStruct.regionBegin = 1
+        writeStruct.regionSize = len(substring)
+        while writeStruct.regionSize < _displaySize[0]:
+            substring += " "
             if attributeMask:
-                writeStruct.attrOr = attributeMask[startPos:endPos]
+                attributeMask += '\x00'
+            writeStruct.regionSize += 1
+        writeStruct.text = substring
+        writeStruct.cursor = cursorCell
+
+        # [[[WDW - if you want to muck around with the dots on the
+        # display to do things such as add underlines, you can use
+        # the attrOr field of the write structure to do so.  The
+        # attrOr field is a string whose length must be the same
+        # length as the display and whose dots will end up showing
+        # up on the display.  Each character represents a bitfield
+        # where each bit corresponds to a dot (i.e., bit 0 = dot 1,
+        # bit 1 = dot 2, and so on).  Here's an example that underlines
+        # all the text.]]]
+        #
+        #myUnderline = ""
+        #for i in range(0, _displaySize[0]):
+        #    myUnderline += '\xc0'
+        #writeStruct.attrOr = myUnderline
 
-            brlAPI.write(writeStruct)
-    else:
-        brl.writeText(cursorCell, substring)
+        if attributeMask:
+            writeStruct.attrOr = attributeMask[startPos:endPos]
+
+        _brlAPI.write(writeStruct)
 
     if settings.enableBrailleMonitor:
         if not monitor:
@@ -1272,7 +1187,7 @@ def _brlAPIKeyReader(source, condition):
     """Method to read a key from the BrlAPI bindings.  This is a
     gobject IO watch handler.
     """
-    key = brlAPI.readKey(False)
+    key = _brlAPI.readKey(False)
     if key:
         #flags = key >> 32
         lower = key & 0xFFFFFFFF
@@ -1289,7 +1204,7 @@ def _brlAPIKeyReader(source, condition):
             keyCode = 0x100 | (keyCode & 0xFF)
         if keyCode:
             _processBrailleEvent(keyCode)
-    return brlAPIRunning
+    return _brlAPIRunning
 
 def setupKeyRanges(keys):
     """Hacky method to tell BrlTTY what to send and not send us via
@@ -1298,64 +1213,24 @@ def setupKeyRanges(keys):
     Arguments:
     -keys: a list of BrlAPI commands.
     """
-    if not brlAPIRunning:
+    if not _brlAPIRunning:
         return
 
-    try:
-        # First, start by ignoring everything.
-        #
-        brlAPI.ignoreKeys(brlapi.rangeType_all, [0])
+    # First, start by ignoring everything.
+    #
+    _brlAPI.ignoreKeys(brlapi.rangeType_all, [0])
 
-        # Next, enable cursor routing keys.
-        #
-        keySet = [brlapi.KEY_TYPE_CMD | brlapi.KEY_CMD_ROUTE]
+    # Next, enable cursor routing keys.
+    #
+    keySet = [brlapi.KEY_TYPE_CMD | brlapi.KEY_CMD_ROUTE]
 
-        # Finally, enable the commands we care about.
-        #
-        for key in keys:
-            keySet.append(brlapi.KEY_TYPE_CMD | key)
+    # Finally, enable the commands we care about.
+    #
+    for key in keys:
+        keySet.append(brlapi.KEY_TYPE_CMD | key)
             
-        brlAPI.acceptKeys(brlapi.rangeType_command, keySet)
-
-        brlAPI.acceptKeys(brlapi.rangeType_key, [65])
-
-        debug.println(debug.LEVEL_FINEST, "Using BrlAPI v0.5.0+")
-    except:
-        debug.printException(debug.LEVEL_FINEST)
-        try:
-            # Old, incompatible way that was in v3.8 devel, but
-            # changed prior to release.  We need this just in case
-            # people have not updated yet.
-
-            # First, start by ignoring everything.
-            #
-            brlAPI.ignoreKeyRange(0,
-                                  brlapi.KEY_FLAGS_MASK \
-                                  | brlapi.KEY_TYPE_MASK \
-                                  | brlapi.KEY_CODE_MASK)
-
-            # Next, enable cursor routing keys.
-            #
-            brlAPI.acceptKeyRange(brlapi.KEY_TYPE_CMD | brlapi.KEY_CMD_ROUTE,
-                                  brlapi.KEY_TYPE_CMD \
-                                  | brlapi.KEY_CMD_ROUTE \
-                                  | brlapi.KEY_CMD_ARG_MASK)
-
-            # Finally, enable the commands we care about.
-            #
-            keySet = []
-            for key in keys:
-                keySet.append(brlapi.KEY_TYPE_CMD | key)
-            if len(keySet):
-                brlAPI.acceptKeySet(keySet)
-
-            debug.println(debug.LEVEL_FINEST,
-                          "Using BrlAPI pre-release v0.5.0")
-        except:
-            debug.printException(debug.LEVEL_FINEST)
-            debug.println(
-                debug.LEVEL_WARNING,
-                "Braille module cannot listen for braille input events")
+    _brlAPI.acceptKeys(brlapi.rangeType_command, keySet)
+    _brlAPI.acceptKeys(brlapi.rangeType_key, [65])
 
 def init(callback=None, tty=7):
     """Initializes the braille module, connecting to the BrlTTY driver.
@@ -1376,55 +1251,42 @@ def init(callback=None, tty=7):
 
     _callback = callback
 
-    if useBrlAPIBindings:
-        try:
-            global brlAPI
-            global brlAPIRunning
-            global brlAPISourceId
+    try:
+        global _brlAPI
+        global _brlAPIRunning
+        global _brlAPISourceId
 
-            gobject.threads_init()
-            brlAPI = brlapi.Connection()
+        gobject.threads_init()
+        _brlAPI = brlapi.Connection()
 
-            try:
-                import os
-                windowPath = os.environ["WINDOWPATH"]
-                brlAPI.enterTtyModeWithPath()
-                brlAPIRunning = True
-                debug.println(\
-                    debug.LEVEL_CONFIGURATION,
-                    "Braille module has been initialized using WINDOWPATH=" \
-                    + "%s" % windowPath)
-            except:
-                brlAPI.enterTtyMode(tty)
-                brlAPIRunning = True
-                debug.println(\
-                    debug.LEVEL_CONFIGURATION,
-                    "Braille module has been initialized using tty=%d" % tty)
-            brlAPISourceId = gobject.io_add_watch(brlAPI.fileDescriptor,
-                                                  gobject.IO_IN,
-                                                  _brlAPIKeyReader)
+        try:
+            import os
+            windowPath = os.environ["WINDOWPATH"]
+            _brlAPI.enterTtyModeWithPath()
+            _brlAPIRunning = True
+            debug.println(\
+                debug.LEVEL_CONFIGURATION,
+                "Braille module has been initialized using WINDOWPATH=" \
+                + "%s" % windowPath)
         except:
-            debug.printException(debug.LEVEL_FINEST)
-            return False
-    else:
-        if brl.init(tty):
-            debug.println(debug.LEVEL_CONFIGURATION,
-                          "Braille module has been initialized.")
-            brl.registerCallback(_processBrailleEvent)
-        else:
-            debug.println(debug.LEVEL_CONFIGURATION,
-                          "Braille module has NOT been initialized.")
-            return False
+            _brlAPI.enterTtyMode(tty)
+            _brlAPIRunning = True
+            debug.println(\
+                debug.LEVEL_CONFIGURATION,
+                "Braille module has been initialized using tty=%d" % tty)
+        _brlAPISourceId = gobject.io_add_watch(_brlAPI.fileDescriptor,
+                                               gobject.IO_IN,
+                                               _brlAPIKeyReader)
+    except:
+        debug.printException(debug.LEVEL_FINEST)
+        return False
 
     # [[[TODO: WDW - For some reason, BrlTTY wants to say the height of the
     # Vario is 40 so we hardcode it to 1 for now.]]]
     #
     #_displaySize = (brl.getDisplayWidth(), brl.getDisplayHeight())
-    if useBrlAPIBindings:
-        (x, y) = brlAPI.displaySize
-        _displaySize = [x, 1]
-    else:
-        _displaySize = [brl.getDisplayWidth(), 1]
+    (x, y) = _brlAPI.displaySize
+    _displaySize = [x, 1]
 
     debug.println(debug.LEVEL_CONFIGURATION,
                   "braille display size = (%d, %d)" \
@@ -1447,17 +1309,14 @@ def shutdown():
     if not _initialized:
         return False
 
-    global brlAPIRunning
-    global brlAPISourceId
+    global _brlAPIRunning
+    global _brlAPISourceId
 
-    if useBrlAPIBindings:
-        if brlAPIRunning:
-            brlAPIRunning = False
-            gobject.source_remove(brlAPISourceId)
-            brlAPISourceId = 0
-            brlAPI.leaveTtyMode()
-    else:
-        brl.shutdown()
+    if _brlAPIRunning:
+        _brlAPIRunning = False
+        gobject.source_remove(_brlAPISourceId)
+        _brlAPISourceId = 0
+        _brlAPI.leaveTtyMode()
 
     _initialized = False
 
diff --git a/src/orca/default.py b/src/orca/default.py
index ed2ac18..1ffe2e0 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -1919,21 +1919,21 @@ class Script(script.Script):
         values are InputEventHandler instances.
         """
         brailleBindings = script.Script.getBrailleBindings(self)
-        brailleBindings[braille.CMD_FWINLT]   = \
+        brailleBindings[braille.brlapi.KEY_CMD_FWINLT]   = \
             self.inputEventHandlers["panBrailleLeftHandler"]
-        brailleBindings[braille.CMD_FWINRT]   = \
+        brailleBindings[braille.brlapi.KEY_CMD_FWINRT]   = \
             self.inputEventHandlers["panBrailleRightHandler"]
-        brailleBindings[braille.CMD_LNUP]     = \
+        brailleBindings[braille.brlapi.KEY_CMD_LNUP]     = \
             self.inputEventHandlers["reviewAboveHandler"]
-        brailleBindings[braille.CMD_LNDN]     = \
+        brailleBindings[braille.brlapi.KEY_CMD_LNDN]     = \
             self.inputEventHandlers["reviewBelowHandler"]
-        brailleBindings[braille.CMD_FREEZE]   = \
+        brailleBindings[braille.brlapi.KEY_CMD_FREEZE]   = \
             self.inputEventHandlers["toggleFlatReviewModeHandler"]
-        brailleBindings[braille.CMD_TOP_LEFT] = \
+        brailleBindings[braille.brlapi.KEY_CMD_TOP_LEFT] = \
             self.inputEventHandlers["reviewHomeHandler"]
-        brailleBindings[braille.CMD_BOT_LEFT] = \
+        brailleBindings[braille.brlapi.KEY_CMD_BOT_LEFT] = \
             self.inputEventHandlers["reviewBottomLeftHandler"]
-        brailleBindings[braille.CMD_HOME]     = \
+        brailleBindings[braille.brlapi.KEY_CMD_HOME]     = \
             self.inputEventHandlers["goBrailleHomeHandler"]
 
         return brailleBindings



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]