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__/chat.cpython-310.pyc
o

S�bֆ�@s�dZdZdZdZdZdZddlZdd	lmZdd
lm	Z	ddlm
Z
ddlmZdd
lmZddlm
Z
ddlmZddlmZddlmZe��ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZdS)z Implements generic chat support.z$Id$z
$Revision$z$Date$z%Copyright (c) 2010-2011 The Orca Team�LGPL�N�)�cmdnames)�debug)�	guilabels)�input_event)�keybindings)�messages)�
orca_state)�settings)�settings_managerc@�DeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�RingListcCsg|_d|_||_d|_dS�Nr)�__data__�__full__�__max__�__cur__)�self�length�r�+/usr/lib/python3/dist-packages/orca/chat.py�__init__4s
zRingList.__init__cCs||jdkr$td|jd�D]}|j|d|j|<q
||j|jd<dS|j�|�|jd7_|j|jkr<d|_dSdS)Nrr)r�rangerr�appendr)r�x�irrrr:s

�zRingList.appendcC�|jS�N)r�rrrr�getE�zRingList.getcCs.|jdkr|j|jd=|jd8_dSdS)Nrr)rrrrrr�removeHs
�zRingList.removecCrr)rrrrr�sizeMr!z
RingList.sizecCrr)rrrrr�maxsizePr!zRingList.maxsizecCsd�|j�S)N�)�joinrrrrr�__str__SszRingList.__str__N)
�__name__�
__module__�__qualname__rrr r"r#r$r'rrrrr3src@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�Conversation�	NcCsZ||_||_||_ttj�|_d}||j��kr(|�d�|d7}||j��ksd|_	dS)aCreates a new instance of the Conversation class.

        Arguments:
        - name: the chatroom/conversation name
        - accHistory: the accessible which holds the conversation history
        - inputArea: the editable text object for this conversation.
        rr%rN)
�name�
accHistory�	inputArearr+�MESSAGE_LIST_LENGTH�_messageHistoryr$�
addMessage�
_typingStatus)rr-r.r/rrrrrbs

�
zConversation.__init__cC�|j�|�dS)z�Adds the current message to the message history.

        Arguments:
        - message: A string containing the message to add
        N)r1r)r�messagerrrr2��zConversation.addMessagecCs|j��}||S)z�Returns the specified message from the message history.

        Arguments:
        - messageNumber: the index of the message to get.
        )r1r )r�
messageNumberr	rrr�
getNthMessage�s
zConversation.getNthMessagecCr)z<Returns the typing status of the buddy in this conversation.�r3rrrr�getTypingStatus�szConversation.getTypingStatuscCs
||_dS)z�Sets the typing status of the buddy in this conversation.

        Arguments:
        - status: a string describing the current status.
        Nr9)r�statusrrr�setTypingStatus��
zConversation.setTypingStatusr)	r(r)r*r0rr2r8r:r<rrrrr+\s
	r+c@r
)�ConversationListcCsVg|_t|�|_t|�|_d}||j��kr)|�dd�|d7}||j��ksdSdS)z�Creates a new instance of the ConversationList class.

        Arguments:
        - messageListLength: the size of the message history to keep.
        rr%Nr)�
conversationsrr1�_roomHistoryr$r2)r�messageListLengthrrrrr�s

�zConversationList.__init__cCs@|sd}n
|�|�s|�|�|j}|j�|�|j�|�dS)z�Adds the current message to the message history.

        Arguments:
        - message: A string containing the message to add
        - conversation: The instance of the Conversation class with which
          the message is associated
        r%N)�hasConversation�addConversationr-r1rr@)rr5�conversationr-rrrr2�s	

zConversationList.addMessagecCs$|j��}|j��}||||fS)z�Returns a list containing the specified message from the message
        history and the name of the chatroom/conversation associated with
        that message.

        Arguments:
        - messageNumber: the index of the message to get.
        )r1r r@)rr7r	�roomsrrr�getNthMessageAndName�s
	
z%ConversationList.getNthMessageAndNamecCs
||jvS)z�Returns True if we know about this conversation.

        Arguments:
        - conversation: the conversation of interest
        )r?�rrDrrrrB�r=z ConversationList.hasConversationcCs
t|j�S)z<Returns the number of conversations we currently know about.)�lenr?rrrr�getNConversations�s
z"ConversationList.getNConversationscCr4)z|Adds conversation to the list of conversations.

        Arguments:
        - conversation: the conversation to add
        N)r?rrGrrrrC�r6z ConversationList.addConversationcCs z	|j�|�WdSYdS)z�Removes conversation from the list of conversations.

        Arguments:
        - conversation: the conversation to remove

        Returns True if conversation was successfully removed.
        FT)r?r"rGrrr�removeConversation�s
�z#ConversationList.removeConversationN)
r(r)r*rr2rFrBrIrCrJrrrrr>�s		r>c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd6d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�ZdS)7�ChatzTThis class implements the chat functionality which is available to
    scripts.
    cCsv||_||_gd�|_tj|_i|_|��|��|_	t
|j�|_t|j�|_
d|_d|_d|_d|_d|_d|_dS)apCreates an instance of the Chat class.

        Arguments:
        - script: the script with which this instance is associated.
        - buddyListAncestries: a list of lists of pyatspi roles beginning
          with the object serving as the actual buddy list (e.g.
          ROLE_TREE_TABLE) and ending with the top level object (e.g.
          ROLE_FRAME).
        )	�F1�F2�F3�F4�F5�F6�F7�F8�F9N)�_script�_buddyListAncestries�messageKeysr�ORCA_MODIFIER_MASK�messageKeyModifier�inputEventHandlers�setupInputEventHandlers�getKeyBindings�keyBindingsrHrAr>�_conversationList�focusedChannelRadioButton�allChannelsRadioButton�allMessagesRadioButton�buddyTypingCheckButton�chatRoomHistoriesCheckButton�speakNameCheckButton)r�script�buddyListAncestriesrrrrs �

z
Chat.__init__cCs\t�|jtj�|jd<t�|jtj�|jd<t�|jtj	�|jd<t�|j
tj�|jd<dS)z�Defines InputEventHandler fields for chat functions which
        will be used by the script associated with this chat instance.�togglePrefixHandler�toggleBuddyTypingHandler�toggleMessageHistoriesHandler�
reviewMessageN)r�InputEventHandler�togglePrefixr�CHAT_TOGGLE_ROOM_NAME_PREFIXrZ�toggleBuddyTyping�CHAT_TOGGLE_BUDDY_TYPING�toggleMessageHistories�CHAT_TOGGLE_MESSAGE_HISTORIES�readPreviousMessage�CHAT_PREVIOUS_MESSAGErrrrr[Ks*��������zChat.setupInputEventHandlersc
Cs�t��}|�t�dtjtj|jd��|�t�dtjtj|jd��|�t�dtjtj|jd��|jD]}|�t�||jtj	|jd��q7|S)z�Defines the chat-related key bindings which will be used by
        the script associated with this chat instance.

        Returns: an instance of keybindings.KeyBindings.
        r%rgrhrirj)
r�KeyBindings�add�
KeyBinding�defaultModifierMask�NO_MODIFIER_MASKrZrWrYrX)rr]�
messageKeyrrrr\esF������
��zChat.getKeyBindingscCsBddlm}|��}|�d�tj}t�d�}|j�	|�|_
|j
�|�|�|j
dddd�tj
}t�d�}|j�	|�|_|j�|�|�|jdddd�tj}t�d�}|j�	|�|_|j�|�|�|jdddd�|��}|�|dd	dd�|�d
tj�}|�d�|�|�|j�dddd�}|�dddd�|�|�|��}|�|�t�d
�}tj}|j�	d|�}|�|tjk�||_|�|jdddd�tj}|j�	d|�}	|	� |�|	�|tj!k�|	|_"|�|j"dddd�tj#|j$j%j&}|j�	d|�}
|
� |�|
�|tj'k�|
|_(|�|j(dddd�|�)�|S)zpReturn a GtkGrid containing the application unique configuration
        GUI items for the current application. r)�Gtk��chatSpeakRoomNamer�chatAnnounceBuddyTyping�chatRoomHistories��z	<b>%s</b>Tg�?�chatMessageVerbosityN)*�
gi.repositoryrz�Grid�set_border_widthr�CHAT_SPEAK_ROOM_NAME�_settingsManager�
getSetting�CheckButton�new_with_mnemonicrd�
set_active�attach�CHAT_ANNOUNCE_BUDDY_TYPINGrb�CHAT_SEPARATE_MESSAGE_HISTORIESrc�Frame�Label�CHAT_SPEAK_MESSAGES_FROM�set_use_markup�set_label_widget�	Alignment�new�set_paddingru�CHAT_SPEAK_MESSAGES_ALL�RadioButtonr�CHAT_SPEAK_ALLra�CHAT_SPEAK_MESSAGES_ACTIVE�
join_group�CHAT_SPEAK_FOCUSED_CHANNELr_�"CHAT_SPEAK_MESSAGES_ALL_IF_FOCUSEDrU�appr-�CHAT_SPEAK_ALL_IF_FOCUSEDr`�show_all)rrz�grid�label�value�
messagesFrame�messagesAlignment�messagesGrid�rb1�rb2�rb3rrr�getAppPreferencesGUI�sf




�





�
zChat.getAppPreferencesGUIcCsJ|j��r	tj}n|j��rtj}ntj}||j��|j��|j	��d�S)z7Returns a dictionary with the app-specific preferences.)r�r|r}r~)
r`�
get_activerr�r_r�r�rdrbrc)r�	verbosityrrr�getPreferencesFromGUI�s

�zChat.getPreferencesFromGUIcC�8tj}t�d�}t�d|�|rtj}|j�|�dS)z� Toggle whether we prefix chat room messages with the name of
        the chat room.

        Arguments:
        - script: the script associated with this event
        - inputEvent: if not None, the input event that caused this action.
        r|T)r	�CHAT_ROOM_NAME_PREFIX_ONr�r��
setSetting�CHAT_ROOM_NAME_PREFIX_OFFrU�presentMessage)rre�
inputEvent�line�
speakRoomNamerrrrl�s	
zChat.togglePrefixcCr�)z� Toggle whether we announce when our buddies are typing a message.

        Arguments:
        - script: the script associated with this event
        - inputEvent: if not None, the input event that caused this action.
        r}T)r	�CHAT_BUDDY_TYPING_ONr�r�r��CHAT_BUDDY_TYPING_OFFrUr�)rrer�r��announceTypingrrrrn�s
�zChat.toggleBuddyTypingcCr�)z� Toggle whether we provide chat room specific message histories.

        Arguments:
        - script: the script associated with this event
        - inputEvent: if not None, the input event that caused this action.
        r~T)r	�CHAT_SEPARATE_HISTORIES_ONr�r�r��CHAT_SEPARATE_HISTORIES_OFFrUr�)rrer�r��
roomHistoriesrrrrps
zChat.toggleMessageHistoriesNrcCs�z	|j�|j�}WnY|j|d}d\}}t�d�r/|�tj�}|r.|�	|�}|j
}n|j�|�\}}|rD|rF|�
||d�dSdSdS)a� Speak/braille a previous chat room message.

        Arguments:
        - script: the script associated with this event
        - inputEvent: if not None, the input event that caused this action.
        - index: The index of the message to read -- by default, the most
          recent message. If we get an inputEvent, however, the value of
          index is ignored and the index of the event_string with respect
          to self.messageKeys is used instead.
        r)NNr~TN)rW�index�event_stringrAr�r��getConversationr
�locusOfFocusr8r-r^rF�utterMessage)rrer�r�r7r5�chatRoomNamerDrrrrrs"

�
��zChat.readPreviousMessageTcCs�t�|jjd�}tjj|jjkr|tjkrdS|s |tj	kr dSd}|r1t�|jjd�r1t
j|}tjs=|jj
�||�}n|jj
�||�}t|���r[|jjj|d�}|jj||d�|j�|�dS)aj Speak/braille a chat room message.

        Arguments:
        - chatRoomName: name of the chat room this message came from
        - message: the chat room message
        - focused: whether or not the current chatroom has focus. Defaults
          to True so that we can use this method to present chat history
          as well as incoming messages.
        r�Nr%r|��string��voice)r��
getAppSettingrUr�r
�activeScriptr-rr�r�r	�CHAT_MESSAGE_FROM_ROOM�presentChatRoomLast�	utilities�appendStringrH�strip�speechGeneratorr��speakMessage�displayBrailleMessage)rr�r5�focusedr��textr�rrrr�<s$
�
zChat.utterMessagecCs|jS)ayGet the actual displayed message. This will almost always be the
        unaltered any_data from an event of type object:text-changed:insert.

        Arguments:
        - event: the Event from which to take the text.

        Returns the string which should be presented as the newly-inserted
        text. (Things like chatroom name prefacing get handled elsewhere.)
        )�any_data�r�eventrrr�getMessageFromEvent`szChat.getMessageFromEventcCs.|r|j�d�r|js
dS|�|j�rdS|�|j�rdS|�|�r+|�||j�dS|�|j�r{|j	j
r:|j	��|�|j�rM|�
|j�}t||j�}n	|�|j�}|j}|�|��d�}|rf|�||�|�|j�}|rpd}|ry|�|||�dS|�|�r�|j}|j	jj|d�}|j	j||d�dSdS)aSGives the Chat class an opportunity to present the text from the
        text inserted Event.

        Arguments:
        - event: the text inserted Event

        Returns True if we handled this event here; otherwise False, which
        tells the associated script that is not a chat event that requires
        custom handling.
        zobject:text-changed:insertFT�
r%r�r�)�type�
startswithr��isGenericTextObject�source�
isInBuddyList�isTypingStatusChangedEvent�presentTypingStatusChange�
isChatRoomMsgrU�flatReviewContext�toggleFlatReviewMode�isNewConversation�getChatRoomNamer+r�r-r�r��addMessageToHistory�
isFocusedChatr��isAutoCompletedTextEventr�r�r�)rr�r-rDr5r�r�r�rrr�presentInsertedTextmsH
��


zChat.presentInsertedTextcCsXt�d�r*|�|j�}|r*||��kr*|jjj|d�}|jj||d�|�	|�dSdS)aCPresents a change in typing status for the current conversation
        if the status has indeed changed and if the user wants to hear it.

        Arguments:
        - event: the accessible Event
        - status: a string containing the status change

        Returns True if we spoke the change; False otherwise
        r}r�r�TF)
r�r�r�r�r:rUr�r�r�r<)rr�r;rDr�rrrr��s

zChat.presentTypingStatusChangecCs|�|�|j�||�dS)aQAdds message to both the individual conversation's history
        as well as to the complete history stored in our conversation
        list.

        Arguments:
        - message: a string containing the message to be added
        - conversation: the instance of the Conversation class to which
          this message belongs
        N)r2r^)rr5rDrrrr��s
zChat.addMessageToHistorycCs(|��}|�tj�r|�tj�rdSdS)z�Returns True if the given accessible seems to be something
        unrelated to the custom handling we're attempting to do here.

        Arguments:
        - obj: the accessible object to examine.
        TF)�getState�contains�pyatspi�STATE_EDITABLE�STATE_SINGLE_LINE�r�obj�staterrrr��s
�zChat.isGenericTextObjectcCs*|r|jD]
}|jj�||�rdSqdS)ayReturns True if obj is the list of buddies in the buddy list
        window. Note that this method relies upon a hierarchical check,
        using a list of hierarchies provided by the script. Scripts
        which have more reliable means of identifying the buddy list
        can override this method.

        Arguments:
        - obj: the accessible being examined
        TF)rVrUr��hasMatchingHierarchy)rr��roleListrrr�isBuddyList�s
�zChat.isBuddyListcCsR|r	|�|�r	dS|jD]}|d}|jj�||gtjg�}|�|�r&dSqdS)z�Returns True if obj is, or is inside of, the buddy list.

        Arguments:
        - obj: the accessible being examined
        - includeList: whether or not the list itself should be
          considered "in" the buddy list.
        TrF)r�rVrUr��ancestorWithRoler��
ROLE_FRAME)rr��includeListr��
buddyListRole�	candidaterrrr��s	
�
�zChat.isInBuddyListcCs|�|�}|j�|�S)z�Returns True if the given accessible is the chat history
        associated with a new conversation.

        Arguments:
        - obj: the accessible object to examine.
        )r�r^rB)rr�rDrrrr�s
zChat.isNewConversationcCsv|sdSd}|��tjtjfvr|���tj�r|�|�}|jj	D]}|r/||j
kr.|Sq!||jkr8|Sq!dS)z�Attempts to locate the conversation associated with obj.

        Arguments:
        - obj: the accessible of interest

        Returns the conversation if found; None otherwise
        Nr%)�getRoler��	ROLE_TEXT�
ROLE_ENTRYr�r�r�r�r^r?r-r.)rr�r-rDrrrr�s 		�

�
�zChat.getConversationcCsJ|r#|��tjkr#|j��tjkr#|��}|�tj�s#|�tj�r#dSdS)z�Returns True if the given accessible is the text object for
        associated with a chat room conversation.

        Arguments:
        - obj: the accessible object to examine.
        TF)	r�r�r��parent�ROLE_SCROLL_PANEr�r�r��STATE_MULTI_LINEr�rrrr�Cs
�zChat.isChatRoomMsgcCs^|r!|���tj�r!|jj�|�}d||f}t�tj	|d�|Sd|}t�tj	|d�dS)z�Returns True if we plan to treat this chat as focused for
        the purpose of deciding whether or not a message should be
        presented to the user.

        Arguments:
        - obj: the accessible object to examine.
        z%INFO: %s's window is focused chat: %sTz*INFO: %s is not focused chat (not showing)F)
r�r�r��
STATE_SHOWINGrUr�� topLevelObjectIsActiveAndCurrentr�println�
LEVEL_INFO)rr��active�msgrrrr�Ts	zChat.isFocusedChatcCs�|jj�|tjtjgtjg�}d}z|jj�|�}|���	�|jj
���	�kr)|}WnY|sb|jj�|tjgtjg�}z|jj�|�}|���	�|jj
���	�krY|}W|SW|SY|S|S)z�Attempts to find the name of the current chat room.

        Arguments:
        - obj: The accessible of interest

        Returns a string containing what we think is the chat room name.
        r%)rUr�r�r��
ROLE_PAGE_TABr��ROLE_APPLICATION�
displayedText�lowerr�r-)rr��ancestorr-r�rrrr�gs6
�����zChat.getChatRoomNamecCsD|j��tjkr
dS|jj��\}}|dkr |jr |jdkr dSdS)z�Returns True if event is associated with text being autocompleted.

        Arguments:
        - event: the accessible event being examined
        F�Tab�	T)r�r�r�r�rUr��lastKeyAndModifiersr�)rr��lastKey�modsrrrr��szChat.isAutoCompletedTextEventcCsdS)z�Returns True if event is associated with a change in typing status.

        Arguments:
        - event: the accessible event being examined
        Frr�rrrr��szChat.isTypingStatusChangedEventr)T)r(r)r*�__doc__rr[r\r�r�rlrnrprrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrKs4,(C

 $
G
%*rK)r�__id__�__version__�__date__�
__copyright__�__license__r�r%rrrrrr	r
rr�
getManagerr�rr+r>rKrrrr�<module>s*)Mq

Youez - 2016 - github.com/yon3zu
LinuXploit