def elten_braille_thread(threadName=None): global stopThreads global eltenmod global eltenbraille global eltenbrailletext oldbraille = eltenbrailletext while (True): if (stopThreads): break time.sleep(0.1) if (eltenmod != None and eltenbraille != None): if (appModuleHandler.getAppModuleForNVDAObject( api.getForegroundObject()) == eltenmod and eltenbraille != None and braille.handler.buffer != eltenbraille and braille.handler.buffer != braille.handler.messageBuffer): braille.handler.buffer = eltenbraille braille.handler.update() elif (braille.handler != None and appModuleHandler.getAppModuleForNVDAObject( api.getForegroundObject()) != eltenmod and braille.handler.buffer == eltenbraille): braille.handler.buffer = braille.handler.mainBuffer braille.handler.update() if oldbraille != eltenbrailletext: oldbraille = eltenbrailletext braille.handler.update()
def getCurrentBrailleTables(input_=False, brf=False): if brf: tables = [ os.path.join(baseDir, "res", "brf.ctb").encode("UTF-8"), os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] else: tables = [] app = appModuleHandler.getAppModuleForNVDAObject( api.getNavigatorObject()) if brailleInput.handler._table.fileName == config.conf["braille"][ "translationTable"] and app and app.appName != "nvda": tables += dictionaries.dictTables if input_: mainTable = os.path.join(brailleTables.TABLES_DIR, brailleInput.handler._table.fileName) else: mainTable = os.path.join( brailleTables.TABLES_DIR, config.conf["braille"]["translationTable"]) tables += [ mainTable, os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] return tables
def getCurrentBrailleTables(input_=False): if input_: if instanceGP.BRFMode and not errorTable: tables = [ os.path.join(configBE.baseDir, "res", "brf.ctb").encode("UTF-8"), os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] else: tables = dictionaries.dictTables+[ os.path.join(brailleTables.TABLES_DIR, brailleInput.handler._table.fileName), os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] else: if errorTable: if instanceGP.BRFMode: instanceGP.BRFMode = False tables = [ os.path.join(brailleTables.TABLES_DIR, config.conf["braille"]["translationTable"]), os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] elif instanceGP.BRFMode: tables = [ os.path.join(configBE.baseDir, "res", "brf.ctb").encode("UTF-8"), os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] else: tables = [] app = appModuleHandler.getAppModuleForNVDAObject(api.getNavigatorObject()) if app and app.appName != "nvda": tables += dictionaries.dictTables tables += configBE.preTable + [ os.path.join(brailleTables.TABLES_DIR, config.conf["braille"]["translationTable"]), os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti") ] + configBE.postTable return tables
def elten_queue_thread(threadName=None): global stopThreads global eltenqueue global eltenpipest global eltenindex global eltenindexid global eltenmod lastSend = 0 while (True): if (stopThreads): break time.sleep(0.01) try: if (eltenpipest != None and eltenpipest != -1 and len(eltenqueue['gestures']) > 0): r = eltenqueue['gestures'][:] eltenqueue['gestures'] = [] j = {'msgtype': 2, 'gestures': r} w = json.dumps(j) + "\n" if (is_python_3_or_above): w = w.encode("utf-8") eltenpipest.write(w) lastSend = time.time() if (eltenpipest != None and eltenpipest != -1 and len(eltenqueue['indexes']) > 0): r = eltenqueue['indexes'][:] eltenqueue['indexes'] = [] j = {'msgtype': 3, 'indexes': r} w = json.dumps(j) + "\n" if (is_python_3_or_above): w = w.encode("utf-8") eltenpipest.write(w) lastSend = time.time() if (eltenpipest != None and eltenpipest != -1 and len(eltenqueue['statuses']) > 0): r = eltenqueue['statuses'][:] eltenqueue['statuses'] = [] j = {'msgtype': 4, 'statuses': r} w = json.dumps(j) + "\n" if (is_python_3_or_above): w = w.encode("utf-8") eltenpipest.write(w) lastSend = time.time() if (eltenpipest != None and eltenpipest != -1 and len(eltenqueue['returns']) > 0): r = eltenqueue['returns'][:] eltenqueue['returns'] = [] for w in r: eltenpipest.write(w) lastSend = time.time() if (lastSend < time.time() - 1 and appModuleHandler.getAppModuleForNVDAObject( api.getForegroundObject()) == eltenmod): eltenqueue['statuses'].append("noop") lastSend = time.time() except Exception as Argument: log.exception("Elten: queue thread") time.sleep(0.05) eltenqueue = { 'gestures': [], 'indexes': [], 'statuses': [], 'returns': [] }
def _get_appModule(self): """Retreaves the appModule representing the application this object is a part of by asking L{appModuleHandler}. @return: the appModule @rtype: L{appModuleHandler.AppModule} """ if not hasattr(self,'_appModuleRef'): a=appModuleHandler.getAppModuleForNVDAObject(self) if a: self._appModuleRef=weakref.ref(a) return a else: return self._appModuleRef()
def _get_appModule(self): """Retreaves the appModule representing the application this object is a part of by asking L{appModuleHandler}. @return: the appModule @rtype: L{appModuleHandler.AppModule} """ if not hasattr(self,'_appModuleRef'): a=appModuleHandler.getAppModuleForNVDAObject(self) if a: self._appModuleRef=weakref.ref(a) return a else: return self._appModuleRef()
def elten_thread(threadName=None): global stopThreads wrongpipeid="" global eltenmod global eltenqueue nvdapipeid="" global eltenpipein global eltenpipeout global eltenpipest eltenpipein=None eltenpipeout=None eltenpipest=None eltendata = os.getenv("appdata")+"\\elten" eltentemp = os.getenv("temp")+"\\elten" nvdapipefile = eltentemp+"\\nvda.pipe" while(1): if(stopThreads): break try: if(nvdapipeid!=""): if(appModuleHandler.getAppModuleForNVDAObject(api.getForegroundObject())==eltenmod): time.sleep(0.001) else: time.sleep(0.1) str=eltenpipein.readline() if(len(str)>0): if(is_python_3_or_above): str=str.decode("utf-8", errors="ignore") j = json.loads(str) id=j['id'] asnc=False if('async' in j): asnc=j['async'] j=elten_command(j) j['id']=id if(asnc!=False): j['msgtype']=1 w=json.dumps(j)+"\n" if(is_python_3_or_above): w=w.encode("utf-8") if(asnc==False): eltenpipeout.write(w) else: eltenqueue['returns'].append(w) else: time.sleep(0.1) if(os.path.isfile(nvdapipefile)): file = open(nvdapipefile,mode='r') pipeid = file.read() file.close() if(pipeid!=nvdapipeid and pipeid!=wrongpipeid): try: nvdapipeid=pipeid eltenpipein=open("\\\\.\\pipe\\"+nvdapipeid+"out", 'rb', 0) eltenpipeout=open("\\\\.\\pipe\\"+nvdapipeid+"in", 'wb', 0) eltenpipest=open("\\\\.\\pipe\\"+nvdapipeid+"st", 'wb', 0) eltenqueue['statuses'].append("connected") if(is_python_3_or_above): eltenqueue['statuses'].append("cbckindexing") except: wrongpipeid=pipeid nvdapipeid="" try: os.remove(nvdapipefile) except: pass elif(nvdapipeid!=""): nvdapipeid="" eltenpipein.close() eltenpipeout.close() eltenpipest.close() eltenpipein=None eltenpipeout=None eltenpipest=None except Exception as Argument: log.exception("Elten: main thread")
def stc(ch): global eltenmod if(appModuleHandler.getAppModuleForNVDAObject(api.getForegroundObject())!=eltenmod): return ostc(ch)