403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/orca/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/orca/__pycache__/settings_manager.cpython-310.pyc
o

S�b6b�	@s�dZdZdZdZdZdZddlZddlZddlZddl	m
Z
mZd	d
lm
Z
d	dlmZd	dlmZd	d
lmZd	dlmZd	dlmZd	dlmZze
j�e
jje
jjddddd�ZWndZYe��ZGdd�de�Z e �Z!dd�ZdS)z\Settings manager module. This will load/save user settings from a 
defined settings backend.z$Id$z
$Revision$z$Date$z2Copyright (c) 2010 Consorcio Fernando de los Rios.�LGPL�N)�Gio�GLib�)�debug)�	orca_i18n)�script_manager)�settings)�pronunciation_dict)�ACSS)�
KeyBindingzorg.a11y.Busz
/org/a11y/buszorg.freedesktop.DBus.Propertiesc@s~eZdZdZdZdd�Zd[dd�Zdifdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd\dd �Zd!d"�Zd]d#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd]d/d0�Zd1d2�Zd^d4d5�Zd6d7�Zd8d9�Zd:d;�Zd\d<d=�Z d\d>d?�Z!d\d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*d_dRdS�Z+dTdU�Z,d`dWdX�Z-dYdZ�Z.dS)a�SettingsManagerz^Settings backend manager. This class manages orca user's settings
    using different backendsNcOs,dt|�vrtj|g|�Ri|��|_|jS)N�
__instance)�vars�object�__new__�_SettingsManager__instance)�cls�args�kwargs�r�7/usr/lib/python3/dist-packages/orca/settings_manager.pyr?szSettingsManager.__new__�jsoncCs�t�tjdd�d|_d|_d|_||_d|_i|_i|_	i|_
i|_i|_i|_
i|_i|_i|_d|_i|_i|_i|_|��sFtd��i|_d|_dg|_t�tjdd�dS)	z�Initialize a SettingsManager Object.
        If backend isn't defined then uses default backend, in this
        case json-backend.
        backend parameter can use the follow values:
        backend='json'
        zSETTINGS MANAGER: InitializingTN�z$SettingsManager._loadBackend failed.F�app-settingszSETTINGS MANAGER: Initialized)r�println�
LEVEL_INFO�
backendModule�_backend�profile�backendName�	_prefsDir�defaultGeneral�defaultPronunciations�defaultKeybindings�profileGeneral�profilePronunciations�profileKeybindings�general�pronunciations�keybindings�
_activeApp�_appGeneral�_appPronunciations�_appKeybindings�_loadBackend�	Exception�customizedSettings�_customizationCompleted�settingsPackages��self�backendrrr�__init__Ds2zSettingsManager.__init__cCst�tjdd�|j�|�|ptj�t�	�d�|_
|j�|j
�|_
|��|��|��|j��|_|��sA|j�|j
���|j��|_|j��|_|��t�tjdd�d|j}t�tj|d�|jdur�|j�d�d|_d|j}t�tj|d�|�|j�dS)	NzSETTINGS MANAGER: ActivatingT�orcazSETTINGS MANAGER: Activatedz'SETTINGS MANAGER: Current profile is %s�startingProfilerz+SETTINGS MANAGER: Current profile is now %s)rrrr1�update�os�path�joinr�get_user_data_dirr!r�Backendr�_setDefaultGeneral�_setDefaultPronunciations�_setDefaultKeybindingsr"�copyr(�isFirstStart�
getGeneralr#r)r$r*�_createDefaultsr�get�
setProfile)r5�prefsDir�customSettings�msgrrr�activateys.�


zSettingsManager.activatecCs,zd|j}t�|d�|_WdSYdS)z.Load specific backend for manage user settingsz.backends.%s_backendr8TF)r �	importlib�
import_modulerr4rrrr/�s
zSettingsManager._loadBackendcCsdd�}|j}||�tj�|d�}||�tj�|d�}tj�|�s.t�t�|tjd��tj�|d�}||�tj�|d�}||�tj�|d�}tj�|�s\t�t�|tjd��tj�|d�}tj�|�stt�t�|tjd��|��r�|j	�
|j|j|j
�d	Sd	S)
z�Let the active backend to create the initial structure
        for storing the settings and save the default ones from
        orca.settingscSstj�|�s
t�|�dSdS�N)r;r<�isdir�makedirs)�dirNamerrr�
_createDir�s�z3SettingsManager._createDefaults.<locals>._createDirzorca-scriptsz__init__.pyi�r�soundszorca-customizations.pyN)r!r;r<r=�exists�close�open�O_CREATrDr�saveDefaultSettingsr"r#r$)r5rS�orcaDir�
orcaScriptDir�initFile�orcaSettingsDir�
orcaSoundsDir�userCustomFilerrrrF�s0
��zSettingsManager._createDefaultscC�
i|_dS)z4Get the pronunciations by default from orca.settingsN)r#�r5rrrrA��
z)SettingsManager._setDefaultPronunciationscCr`)z1Get the keybindings by default from orca.settingsN)r$rarrrrB�rbz&SettingsManager._setDefaultKeybindingscCsT|��i|_tjD]}|j�|�}|dur"ztt|�}WnY||j|<q
dS)z6Get the general settings by default from orca.settingsN)�_getCustomizedSettingsr"r	�userCustomizableSettingsr1rG�getattr)r5�key�valuerrrr@�s
�z"SettingsManager._setDefaultGeneralcCsj|jr|jSi}tj��D]\}}|||<q
|��|_|��D]\}}tj�|�}||kr2||j|<qdSrO)r2r1r	�__dict__�items�_loadUserCustomizationsrG)r5�originalSettingsrfrg�customValuerrrrc�s


��z&SettingsManager._getCustomizedSettingscCs�d}|jg}zd}t�d|�\}}}|d|7}t�d|||�Wnty0d}|d7}Ynty9YdSw|d7}|��d}t�tj	|d�|S)z�Attempt to load the user's orca-customizations. Returns a boolean
        indicating our success at doing so, where success is measured by the
        likelihood that the results won't be different if we keep trying.Fz6SETTINGS MANAGER: Attempt to load orca-customizations zorca-customizationszfrom %s Tz%failed due to ImportError. Giving up.z
succeeded.)
r!�imp�find_module�load_module�ImportError�AttributeErrorrVrr�	LEVEL_ALL)r5�success�pathListrK�fileHnd�
moduleName�descrrrrj�s&
��z'SettingsManager._loadUserCustomizationscC�|jSrO)r!rarrr�getPrefsDir�zSettingsManager.getPrefsDircCs|�||i�dSrO)�_setSettingsRuntime)r5�settingName�settingValuerrr�
setSettingszSettingsManager.setSettingcCstt|d�SrO)rer	)r5r|rrr�
getSettingszSettingsManager.getSetting�defaultcCsR|�d�}t|�|i��}|��}|��}|r'tt|��dkr'd||��f}|S)N�voices�z%s_%s)rrrG�	getLocale�
getDialect�len�str�upper)r5�voicer��v�lang�dialectrrr�getVoiceLocales
zSettingsManager.getVoiceLocalec	Csng}|�d�D]-}zt�d|�}|�|�d|}t�tj|d�Wqd|}t�tj|d�Yq|S)z/Imports all known SpeechServer factory modules.�speechFactoryModuleszorca.%sz1SETTINGS MANAGER: Valid speech server factory: %sTz3SETTINGS MANAGER: Invalid speech server factory: %s)rrMrN�appendrrr)r5�	factoriesrv�modulerKrrr�getSpeechServerFactories"s
z(SettingsManager.getSpeechServerFactoriescCsrd|}t�tj|d�|dur|j}|�|�pi|_|�|�p!i|_|�|�p)i|_	d|}t�tj|d�dS)z�Get from the active backend all the settings for the current
        profile and store them in the object's attributes.
        A profile can be passed as a parameter. This could be useful for
        change from one profile to another.z1SETTINGS MANAGER: Loading settings for %s profileTNz0SETTINGS MANAGER: Settings for %s profile loaded)
rrrr�getGeneralSettingsr%�getPronunciationsr&�getKeybindingsr')r5rrKrrr�_loadProfileSettings2sz$SettingsManager._loadProfileSettingscCs�d}t�tj|d�|j�|j�|j�|j�|j�|j	�|j
�|j�|j�|j�|j�|j�d}t�tj|d�dS)z^Update the changed values on the profile settings
        over the current and active settingsz#SETTINGS MANAGER: Merging settings.Tz"SETTINGS MANAGER: Settings merged.N)
rrrr%r:r,r&r-r'r.r(r)r*)r5rKrrr�_mergeSettingsDszSettingsManager._mergeSettingscCs|��}|s|�d�|S)z�Enables the GNOME accessibility flag.  Users need to log out and
        then back in for this to take effect.

        Returns True if an action was taken (i.e., accessibility was not
        set prior to this call).
        T)�isAccessibilityEnabled�setAccessibility)r5�alreadyEnabledrrr�_enableAccessibilityVs
z$SettingsManager._enableAccessibilitycCsXd}t�tj|d�d}tsd}|d7}n
t�ddd�}|t|�7}t�tj|d�|S)	Nz7SETTINGS MANAGER: Checking if accessibility is enabled.Tz)SETTINGS MANAGER: Accessibility enabled: F�Error (no proxy)�(ss)�org.a11y.Status�	IsEnabled)rrr�_proxy�Getr��r5rK�rvrrrr�ds
z&SettingsManager.isAccessibilityEnabledcCsld|}t�tj|d�tsd}t�tj|d�dSt�d|�}t�ddd|�d	|}t�tj|d�dS)
Nz8SETTINGS MANAGER: Attempting to set accessibility to %s.Tz"SETTINGS MANAGER: Error (no proxy)F�bz(ssv)r�r�z7SETTINGS MANAGER: Finished setting accessibility to %s.)rrrr�r�Variant�Set)r5�enablerK�vEnablerrrr�ssz SettingsManager.setAccessibilitycCsDd}tsd}|d7}n
t�ddd�}|t|�7}t�tj|d�|S)z�Returns True if the screen reader service is enabled. Note that
        this does not necessarily mean that Orca (or any other screen reader)
        is running at the moment.z4SETTINGS MANAGER: Is screen reader service enabled? Fr�r�r��ScreenReaderEnabledT)r�r�r�rrrr�rrr�isScreenReaderServiceEnabled�s
z,SettingsManager.isScreenReaderServiceEnabledcCs |durtj}|j�d|�dS)Nr9)r	rr�_setProfileKey�r5rrrr�setStartingProfile�sz"SettingsManager.setStartingProfilecCrxrO)rrarrr�
getProfile�rzzSettingsManager.getProfileFcCs�d|}t�tj|d�|�d�}||_|�|�|��|�|j�|s'dS|�d�}||kr?t	�
|�t	�|�t	�|�d|}t�tj|d�dS)z�Set a specific profile as the active one.
        Also the settings from that profile will be loading
        and updated the current settings with them.z(SETTINGS MANAGER: Setting profile to: %sTr�Nz$SETTINGS MANAGER: Profile set to: %s)
rrrr�rr�r�r{r(r�setLocaleForNames�setLocaleForMessages�setLocaleForGUI)r5r�updateLocalerK�oldVoiceLocale�newVoiceLocalerrrrH�s 





zSettingsManager.setProfilecCs|j�|�dSrO)r�
removeProfiler�rrrr��szSettingsManager.removeProfilecCszd}t�tj|d�|��D]\}}ttt|�|�q|��|j��D]\}}ttt|�|�q$d}t�tj|d�dS)Nz+SETTINGS MANAGER: Setting runtime settings.Tz'SETTINGS MANAGER: Runtime settings set.)	rrrri�setattrr	r�rcr1)r5�settingsDictrKrfrgrrrr{�sz#SettingsManager._setSettingsRuntimecCs0it_|��D]\}}|r|rt�||�qdSrO)r
�values�setPronunciation)r5�pronunciationsDictrfrgrrr�_setPronunciationsRuntime�s��z)SettingsManager._setPronunciationsRuntimecC�|j�|�S)z�Return the current general settings.
        Those settings comes from updating the default settings
        with the profiles' ones)rrEr�rrrr���z"SettingsManager.getGeneralSettingscCr�)z�Return the current pronunciations settings.
        Those settings comes from updating the default settings
        with the profiles' ones)rr�r�rrrr��r�z!SettingsManager.getPronunciationscCr�)z�Return the current keybindings settings.
        Those settings comes from updating the default settings
        with the profiles' ones)rr�r�rrrr��r�zSettingsManager.getKeybindingscCs�d}t�tj|d�i|_|��D].\}}|dvrq|dkr$||j|<q||j�|�kr2||j|<q|j�|�|kr?||j|<qd}t�tj|d�dS)zRSet the changed general settings from the defaults' ones
        as the profile's.z6SETTINGS MANAGER: Setting general settings for profileT)r9�
activeProfilerz2SETTINGS MANAGER: General settings for profile setN)rrrr%rir"rGr()r5r(rKrfrgrrr�_setProfileGeneral�s
�z"SettingsManager._setProfileGeneralcC�Dd}t�tj|d�|j��|_|j�|�d}t�tj|d�dS)zYSet the changed pronunciations settings from the defaults' ones
        as the profile's.z=SETTINGS MANAGER: Setting pronunciation settings for profile.Tz9SETTINGS MANAGER: Pronunciation settings for profile set.N)rrrr#rCr&r:)r5r)rKrrr�_setProfilePronunciations��z)SettingsManager._setProfilePronunciationscCr�)zVSet the changed keybindings settings from the defaults' ones
        as the profile's.z;SETTINGS MANAGER: Setting keybindings settings for profile.Tz7SETTINGS MANAGER: Keybindings settings for profile set.N)rrrr$rCr'r:)r5r*rKrrr�_setProfileKeybindingsr�z&SettingsManager._setProfileKeybindingsc
Cs�i}|�|j�}|��D]\}}||�|�kr|||<qi}	|�|j�}
|��D]\}}||
�|�kr7||	|<q(i}|�|j�}|��D]\}}||�|�krS|||<qD|j�||j||	|�dSrO)r�rrirGr�r�r�saveAppSettings)
r5�appNamer(r)r*�
appGeneralr%rfrg�appPronunciationsr&�appKeybindingsr'rrr�_saveAppSettingss0����z SettingsManager._saveAppSettingsc	Cs�d||jf}t�tj|d�|j}|r|�|j|||�dS|�dtj�}|d}||_|�d|�|j	d<|�
|�|�|�|�|�d|j
}t�tj|d�|j
�|j|j|j|j�d||jf}t�tj|d�|��S)	z3Save the settings provided for the script provided.z2SETTINGS MANAGER: Saving settings for %s (app: %s)TNrrr9z'SETTINGS MANAGER: Saving for backend %sz1SETTINGS MANAGER: Settings for %s (app: %s) saved)�apprrrr��namerGr	rr"r�r�r�r�saveProfileSettingsr%r&r'r�)	r5�scriptr(r)r*rKr��_profile�currentProfilerrr�saveSettings's2
�




�zSettingsManager.saveSettingscCs4|\}}}}|sd}|S|t|�t|�t|�f}|S)zAConverts the values of bindingTuple into KeyBinding-ready values.)rrrr)�int)r5�bindingTuple�keysym�mask�mods�clicksrrr�_adjustBindingTupleValuesMs�z)SettingsManager._adjustBindingTupleValuesc
Csr|j}|��D]/\}}|j�|�}|sq|�|�|D]}|�|�}|\}}	}
}t||	|
||�}|�|�qq|SrO)r'ri�inputEventHandlersrG�removeByHandlerr�r�add)
r5r��scriptKeyBindings�keybindingsSettings�
handlerString�
bindingTuples�handlerr�r�r�r�r��
newBindingrrr�overrideKeyBindingsXs

�z#SettingsManager.overrideKeyBindingscC�
|j��S)z,Check if the firstStart key is True or false)rrDrarrrrDhrbzSettingsManager.isFirstStartcCs|j�|�dS)z�Set firstStart. This user-configurable setting is primarily
        intended to serve as an indication as to whether or not initial
        configuration is needed.N)r�
setFirstStart)r5rgrrrr�lszSettingsManager.setFirstStartcCr�)z*Get available profiles from active backend)r�availableProfilesrarrrr�rs
z!SettingsManager.availableProfilesTc	Csn|sdS|j�|j�}|�di�}|�|ji�}|�di�}|�|�}|dur5|r5|j�|j�}|�|�}|S)N�profilesr()r�getAppSettingsr�rGrrE)	r5r�r|�fallbackOnDefault�appPrefsr��profilePrefsr(�
appSettingrrr�
getAppSettingws

zSettingsManager.getAppSettingcCs�|r|jsdS|j��D]}|j�|�q|j�|jj�}|�di�}|�|j	i�}|�di�|_
|�di�|_|�di�|_|jj|_|�
�|��|�|j�|�|j�|�||���|_dS)z�Load the users application specific settings for an app.

        Arguments:
        - script: the current active script.
        Nr�r(r*r))r�r-�keysr)�poprr�r�rGrr,r.r+r�r�r{r(r�r��getKeyBindings�keyBindings)r5r�rf�prefsr�r�rrr�loadAppSettings�s 

zSettingsManager.loadAppSettings)r)r�rO)r�F)F)T)/�__name__�
__module__�__qualname__�__doc__�	_instancerr7rLr/rFrArBr@rcrjryr~rr�r�r�r�r�r�r�r�r�r�rHr�r{r�r�r�r�r�r�r�r�r�r�r�rDr�r�r�r�rrrrr
:sZ
5%
+

	







&

r
cCstSrO)�_managerrrrr�
getManager�sr�)"r��__id__�__version__�__date__�
__copyright__�__license__rmrMr;�
gi.repositoryrrrrrrr	r
�acssrr*r�	DBusProxy�new_for_bus_sync�BusType�SESSION�DBusProxyFlags�NONEr�r��_scriptManagerrr
r�rrrr�<module>sJ�l

Youez - 2016 - github.com/yon3zu
LinuXploit