Ë
    g
f›…  ã                   óü   — d Z dZdZdZdZdZddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Zy)z Implements generic chat support.z$Id$z
$Revision$z$Date$z%Copyright (c) 2010-2011 The Orca TeamÚLGPLé   )Úcmdnames)Údebug)Úfocus_manager)Ú	guilabels)Úinput_event)Úkeybindings)Úmessages)Úscript_manager)Úsettings)Úsettings_manager)ÚAXObject)ÚAXUtilitiesc                   ó6   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚRingListc                 ó<   — g | _         d| _        || _        d| _        y ©Né    )Ú__data__Ú__full__Ú__max__Ú__cur__)ÚselfÚlengths     ú+/usr/lib/python3/dist-packages/orca/chat.pyÚ__init__zRingList.__init__3   s   € ØˆŒØˆŒØˆŒØˆ�ó    c                 óx  — | j                   dk(  rZt        d| j                  dz
  «      D ]!  }| j                  |dz      | j                  |<   Œ# || j                  | j                  dz
  <   y | j                  j	                  |«       | xj                  dz  c_        | j                  | j
                  k(  rd| _         y y )Nr   r   )r   Úranger   r   Úappendr   )r   ÚxÚis      r   r    zRingList.append9   s›   € Ø�=‰=˜AÒÜ˜A˜tŸ|™|¨aÑ/Ó0ò 8�Ø#'§=¡=°°Q±Ñ#7�—‘˜aÒ ð8à./ˆD�M‰M˜$Ÿ,™,¨Ñ*Ò+à�M‰M× Ñ  Ô#Ø�LŠL˜AÑ�LØ�|‰|˜tŸ|™|Ò+Ø !�•ð ,r   c                 ó   — | j                   S ©N)r   ©r   s    r   ÚgetzRingList.getD   s   € Ø�}‰}Ðr   c                 ó‚   — | j                   dkD  r0| j                  | j                   dz
  = | xj                   dz  c_         y y )Nr   r   )r   r   r%   s    r   ÚremovezRingList.removeG   s6   € Ø�L‰L˜1ÒØ—‘˜dŸl™l¨QÑ.Ð/Ø�LŠL˜AÑŽLð r   c                 ó   — | j                   S r$   )r   r%   s    r   ÚsizezRingList.sizeL   ó   € Ø�|‰|Ðr   c                 ó   — | j                   S r$   )r   r%   s    r   ÚmaxsizezRingList.maxsizeO   r+   r   c                 ó8   — dj                  | j                  «      S )NÚ )Újoinr   r%   s    r   Ú__str__zRingList.__str__R   s   € Ø�w‰w�t—}‘}Ó%Ð%r   N)
Ú__name__Ú
__module__Ú__qualname__r   r    r&   r(   r*   r-   r1   © r   r   r   r   2   s%   „ òò	"òòò
òó&r   r   c                   ó0   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zy)	ÚConversationé	   Nc                 ó  — || _         || _        || _        t        t        j
                  «      | _        d}|| j                  j                  «       k  r4| j                  d«       |dz  }|| j                  j                  «       k  rŒ4d| _	        y)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.
        r   r/   r   N)
ÚnameÚ
accHistoryÚ	inputArear   r7   ÚMESSAGE_LIST_LENGTHÚ_messageHistoryr-   Ú
addMessageÚ_typingStatus)r   r:   r;   r<   r"   s        r   r   zConversation.__init__a   s„   € ð ˆŒ	Ø$ˆŒØ"ˆŒô  (¬×(HÑ(HÓIˆÔð ˆØ�$×&Ñ&×.Ñ.Ó0Ò0Ø�O‰O˜BÔØ�‰FˆAð �$×&Ñ&×.Ñ.Ó0Ó0ð  ˆÕr   c                 ó:   — | j                   j                  |«       y)z‡Adds the current message to the message history.

        Arguments:
        - message: A string containing the message to add
        N)r>   r    )r   Úmessages     r   r?   zConversation.addMessage€   s   € ð 	×Ñ×#Ñ# GÕ,r   c                 ó@   — | j                   j                  «       }||   S )zŽReturns the specified message from the message history.

        Arguments:
        - messageNumber: the index of the message to get.
        )r>   r&   )r   ÚmessageNumberr
   s      r   ÚgetNthMessagezConversation.getNthMessage‰   s#   € ð ×'Ñ'×+Ñ+Ó-ˆà˜Ñ&Ð&r   c                 ó   — | j                   S )z<Returns the typing status of the buddy in this conversation.©r@   r%   s    r   ÚgetTypingStatuszConversation.getTypingStatus”   s   € ð ×!Ñ!Ð!r   c                 ó   — || _         y)z�Sets the typing status of the buddy in this conversation.

        Arguments:
        - status: a string describing the current status.
        NrG   )r   Ústatuss     r   ÚsetTypingStatuszConversation.setTypingStatus™   s   € ð $ˆÕr   r$   )	r2   r3   r4   r=   r   r?   rE   rH   rK   r5   r   r   r7   r7   [   s#   „ ð Ðó ò>-ò	'ò"ó
$r   r7   c                   ó6   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚConversationListc                 óü   — g | _         t        |«      | _        t        |«      | _        d}|| j                  j	                  «       k  r6| j                  dd«       |dz  }|| j                  j	                  «       k  rŒ5yy)z˜Creates a new instance of the ConversationList class.

        Arguments:
        - messageListLength: the size of the message history to keep.
        r   r/   Nr   )Úconversationsr   r>   Ú_roomHistoryr-   r?   )r   ÚmessageListLengthr"   s      r   r   zConversationList.__init__ª   sz   € ð  ˆÔô
  (Ð(9Ó:ˆÔô
 %Ð%6Ó7ˆÔð ˆØ�$×&Ñ&×.Ñ.Ó0Ò0Ø�O‰O˜B Ô%Ø�‰FˆAð �$×&Ñ&×.Ñ.Ó0Õ0r   c                 óÖ   — |sd}n.| j                  |«      s| j                  |«       |j                  }| j                  j	                  |«       | j
                  j	                  |«       y)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:   r>   r    rP   )r   rB   Úconversationr:   s       r   r?   zConversationList.addMessageÅ   s[   € ñ Ø‰Dà×'Ñ'¨Ô5Ø×$Ñ$ \Ô2Ø×$Ñ$ˆDà×Ñ×#Ñ# GÔ,Ø×Ñ× Ñ  Õ&r   c                 ó~   — | j                   j                  «       }| j                  j                  «       }||   ||   fS )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.
        )r>   r&   rP   )r   rD   r
   Úroomss       r   ÚgetNthMessageAndNamez%ConversationList.getNthMessageAndNameØ   sA   € ð ×'Ñ'×+Ñ+Ó-ˆØ×!Ñ!×%Ñ%Ó'ˆà˜Ñ&¨¨mÑ(<Ð<Ð<r   c                 ó   — || j                   v S )z‚Returns True if we know about this conversation.

        Arguments:
        - conversation: the conversation of interest
        )rO   ©r   rU   s     r   rS   z ConversationList.hasConversationæ   s   € ð ˜t×1Ñ1Ð1Ð1r   c                 ó,   — t        | j                  «      S )z<Returns the number of conversations we currently know about.)ÚlenrO   r%   s    r   ÚgetNConversationsz"ConversationList.getNConversationsï   s   € ô �4×%Ñ%Ó&Ð&r   c                 ó:   — | j                   j                  |«       y)z|Adds conversation to the list of conversations.

        Arguments:
        - conversation: the conversation to add
        N)rO   r    rZ   s     r   rT   z ConversationList.addConversationô   s   € ð 	×Ñ×!Ñ! ,Õ/r   c                 óZ   — 	 | j                   j                  |«       y# t        $ r Y yw xY w)zÄRemoves conversation from the list of conversations.

        Arguments:
        - conversation: the conversation to remove

        Returns True if conversation was successfully removed.
        TF)rO   r(   Ú	ExceptionrZ   s     r   ÚremoveConversationz#ConversationList.removeConversationý   s4   € ð	Ø×Ñ×%Ñ% lÔ3ð øô ò 	Ùð	ús   ‚ ž	*©*N)
r2   r3   r4   r   r?   rX   rS   r]   rT   ra   r5   r   r   rM   rM   ¨   s%   „ òò6'ò&=ò2ò'ò
0ór   rM   c                   ó¦   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zdd„Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy
)ÚChatzTThis class implements the chat functionality which is available to
    scripts.
    c                 óp  — || _         || _        g d¢| _        t        j                  | _        i | _        | j                  «        | j                  «       | _	        t        | j                  «      | _        t        | j                  «      | _        d| _        d| _        d| _        d| _        d| _        d| _        y)ah  Creates an instance of the Chat class.

        Arguments:
        - script: the script with which this instance is associated.
        - buddyListAncestries: a list of lists of 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ÚkeyBindingsr\   rQ   rM   Ú_conversationListÚfocusedChannelRadioButtonÚallChannelsRadioButtonÚallMessagesRadioButtonÚbuddyTypingCheckButtonÚchatRoomHistoriesCheckButtonÚspeakNameCheckButton)r   ÚscriptÚbuddyListAncestriess      r   r   zChat.__init__  s¬   € ð ˆŒØ$7ˆÔ!ò Cð 	Ôä"-×"@Ñ"@ˆÔØ"$ˆÔØ×$Ñ$Ô&Ø×.Ñ.Ó0ˆÔô
 "% T×%5Ñ%5Ó!6ˆÔÜ!1°$×2HÑ2HÓ!IˆÔà)-ˆÔ&Ø&*ˆÔ#Ø&*ˆÔ#Ø&*ˆÔ#Ø,0ˆÔ)Ø$(ˆÕ!r   c                 óÜ  — t        j                  | j                  t        j                  «      | j
                  d<   t        j                  | j                  t        j                  «      | j
                  d<   t        j                  | j                  t        j                  «      | j
                  d<   t        j                  | j                  t        j                  «      | j
                  d<   y)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_PREFIXrs   ÚtoggleBuddyTypingÚCHAT_TOGGLE_BUDDY_TYPINGÚtoggleMessageHistoriesÚCHAT_TOGGLE_MESSAGE_HISTORIESÚreadPreviousMessageÚCHAT_PREVIOUS_MESSAGEr%   s    r   rt   zChat.setupInputEventHandlersH  sÒ   € ô
 ×)Ñ)Ø×!Ñ!Ü×5Ñ5ó7ð 	×ÑÐ 5Ñ6ô ×)Ñ)Ø×&Ñ&Ü×1Ñ1ó3ð 	×ÑÐ :Ñ;ô ×)Ñ)Ø×+Ñ+Ü×6Ñ6ó8ð 	×ÑÐ ?Ñ@ô ×)Ñ)Ø×(Ñ(Ü×.Ñ.ó0ð 	×Ñ Ñ0ð
 	r   c           
      óÈ  — t        j                  «       }|j                  t        j                  dt         j                  t         j
                  | j                  d   «      «       |j                  t        j                  dt         j                  t         j
                  | j                  d   «      «       |j                  t        j                  dt         j                  t         j
                  | j                  d   «      «       | j                  D ]N  }|j                  t        j                  || j                  t         j                  | j                  d   «      «       ŒP |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/   r�   r‚   rƒ   r„   )
r	   ÚKeyBindingsÚaddÚ
KeyBindingÚdefaultModifierMaskÚNO_MODIFIER_MASKrs   rp   rr   rq   )r   rv   Ú
messageKeys      r   ru   zChat.getKeyBindingsb  s2  € ô "×-Ñ-Ó/ˆà�‰Ü×"Ñ"ØÜ×/Ñ/Ü×,Ñ,Ø×'Ñ'Ð(=Ñ>ó	@ô	Að 	�‰Ü×"Ñ"ØÜ×/Ñ/Ü×,Ñ,Ø×'Ñ'Ð(BÑCó	Eô	Fð 	�‰Ü×"Ñ"ØÜ×/Ñ/Ü×,Ñ,Ø×'Ñ'Ð(GÑHó	Jô	Kð ×*Ñ*ò 	?ˆJØ�O‰OÜ×&Ñ&ØØ×+Ñ+Ü×2Ñ2Ø×+Ñ+¨OÑ<ó	>õ?ð	?ð Ðr   c                 óô  — ddl m} |j                  «       }|j                  d«       t        j
                  }t        j                  «       j                  d«      }|j                  j                  |«      | _        | j                  j                  |«       |j                  | j                  dddd«       t        j                  }t        j                  «       j                  d«      }|j                  j                  |«      | _        | j                  j                  |«       |j                  | j                  dddd«       t        j                   }t        j                  «       j                  d«      }|j                  j                  |«      | _        | j"                  j                  |«       |j                  | j"                  dddd«       |j%                  «       }|j                  |dd	dd«       |j'                  d
t        j(                  › d�«      }|j+                  d«       |j-                  |«       |j.                  j1                  dddd«      }|j3                  dddd«       |j5                  |«       |j                  «       }|j5                  |«       t        j                  «       j                  d«      }t        j6                  }|j8                  j                  d|«      }|j                  |t:        j<                  k(  «       || _        |j                  | j>                  dddd«       t        j@                  }|j8                  j                  d|«      }	|	jC                  |«       |	j                  |t:        jD                  k(  «       |	| _#        |j                  | jF                  dddd«       t        jH                  tK        jL                  | jN                  jP                  «      z  }|j8                  j                  d|«      }
|
jC                  |«       |
j                  |t:        jR                  k(  «       |
| _*        |j                  | jT                  dddd«       |jW                  «        |S )zpReturn a GtkGrid containing the application unique configuration
        GUI items for the current application. r   )ÚGtké   ÚchatSpeakRoomNamer   ÚchatAnnounceBuddyTypingÚchatRoomHistoriesé   é   z<b>z</b>Tg      à?ÚchatMessageVerbosityN),Úgi.repositoryr–   ÚGridÚset_border_widthr   ÚCHAT_SPEAK_ROOM_NAMEr   Ú
getManagerÚ
getSettingÚCheckButtonÚnew_with_mnemonicr}   Ú
set_activeÚattachÚCHAT_ANNOUNCE_BUDDY_TYPINGr{   ÚCHAT_SEPARATE_MESSAGE_HISTORIESr|   ÚFrameÚLabelÚCHAT_SPEAK_MESSAGES_FROMÚset_use_markupÚset_label_widgetÚ	AlignmentÚnewÚset_paddingr�   ÚCHAT_SPEAK_MESSAGES_ALLÚRadioButtonr   ÚCHAT_SPEAK_ALLrz   ÚCHAT_SPEAK_MESSAGES_ACTIVEÚ
join_groupÚCHAT_SPEAK_FOCUSED_CHANNELrx   Ú"CHAT_SPEAK_MESSAGES_ALL_IF_FOCUSEDr   Úget_namern   ÚappÚCHAT_SPEAK_ALL_IF_FOCUSEDry   Úshow_all)r   r–   ÚgridÚlabelÚvalueÚmessagesFrameÚmessagesAlignmentÚmessagesGridÚrb1Úrb2Úrb3s              r   ÚgetAppPreferencesGUIzChat.getAppPreferencesGUIŠ  s‚  € õ 	&à�x‰x‹zˆØ×Ñ˜bÔ!ä×.Ñ.ˆÜ ×+Ñ+Ó-×8Ñ8Ð9LÓMˆØ$'§O¡O×$EÑ$EÀeÓ$LˆÔ!Ø×!Ñ!×,Ñ,¨UÔ3Ø�‰�D×-Ñ-¨q°!°Q¸Ô:ä×4Ñ4ˆÜ ×+Ñ+Ó-×8Ñ8Ð9RÓSˆØ&)§o¡o×&GÑ&GÈÓ&NˆÔ#Ø×#Ñ#×.Ñ.¨uÔ5Ø�‰�D×/Ñ/°°A°q¸!Ô<ä×9Ñ9ˆÜ ×+Ñ+Ó-×8Ñ8Ð9LÓMˆà�O‰O×-Ñ-¨eÓ4ð 	Ô)à×)Ñ)×4Ñ4°UÔ;Ø�‰�D×5Ñ5°q¸!¸QÀÔBàŸ	™	›ˆØ�‰�M 1 a¨¨AÔ.Ø—	‘	˜C¤	× BÑ BÐCÀ4ÐHÓIˆØ×Ñ˜TÔ"Ø×&Ñ& uÔ-àŸM™M×-Ñ-¨c°3¸¸1Ó=ÐØ×%Ñ% a¨¨B°Ô2Ø×ÑÐ+Ô,Ø—x‘x“zˆØ×Ñ˜lÔ+ä ×+Ñ+Ó-×8Ñ8Ð9OÓPˆä×1Ñ1ˆØ�o‰o×/Ñ/°°eÓ<ˆØ�‰�u¤× 7Ñ 7Ñ7Ô8Ø&)ˆÔ#Ø×Ñ˜D×7Ñ7¸¸A¸qÀ!ÔDä×4Ñ4ˆØ�o‰o×/Ñ/°°eÓ<ˆØ�‰�sÔØ�‰�u¤× CÑ CÑCÔDØ),ˆÔ&Ø×Ñ˜D×:Ñ:¸A¸qÀ!ÀQÔGä×<Ñ<Ü×Ñ˜dŸl™l×.Ñ.Ó/ñ0ˆà�o‰o×/Ñ/°°eÓ<ˆØ�‰�sÔØ�‰�u¤× BÑ BÑBÔCØ&)ˆÔ#Ø×Ñ˜D×7Ñ7¸¸A¸qÀ!ÔDà�‰Œàˆr   c                 ól  — | j                   j                  «       rt        j                  }n;| j                  j                  «       rt        j
                  }nt        j                  }|| j                  j                  «       | j                  j                  «       | j                  j                  «       dœS )z7Returns a dictionary with the app-specific preferences.)r�   r˜   r™   rš   )
ry   Ú
get_activer   r»   rx   r·   r´   r}   r{   r|   )r   Ú	verbositys     r   ÚgetPreferencesFromGUIzChat.getPreferencesFromGUIÍ  sŽ   € ð ×&Ñ&×1Ñ1Ô3Ü ×:Ñ:‰IØ×+Ñ+×6Ñ6Ô8Ü ×;Ñ;‰Iä ×/Ñ/ˆIð %.Ø!%×!:Ñ!:×!EÑ!EÓ!GØ'+×'BÑ'B×'MÑ'MÓ'OØ!%×!BÑ!B×!MÑ!MÓ!Oñ	
ð 	
r   c                 ó  — t         j                  }t        j                  «       j	                  d«      }t        j                  «       j                  d| «       |rt         j                  }| j                  j                  |«       y)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¢   r£   Ú
setSettingÚCHAT_ROOM_NAME_PREFIX_OFFrn   ÚpresentMessage)r   r~   Ú
inputEventÚlineÚspeakRoomNames        r   r†   zChat.togglePrefixä  si   € ô ×0Ñ0ˆÜ(×3Ñ3Ó5×@Ñ@ÐATÓUˆÜ×#Ñ#Ó%×0Ñ0Ð1DÈ-ÐFWÔXÙÜ×5Ñ5ˆDØ�‰×#Ñ# DÔ)àr   c                 ó  — t         j                  }t        j                  «       j	                  d«      }t        j                  «       j                  d| «       |rt         j                  }| j                  j                  |«       y)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£   rÍ   ÚCHAT_BUDDY_TYPING_OFFrn   rÏ   )r   r~   rÐ   rÑ   ÚannounceTypings        r   rˆ   zChat.toggleBuddyTypingö  sk   € ô ×,Ñ,ˆÜ)×4Ñ4Ó6×AÑAÐB[Ó\ˆÜ×#Ñ#Ó%×0Ñ0Ø%¨>Ð'9ô	;áÜ×1Ñ1ˆDØ�‰×#Ñ# DÔ)àr   c                 ó  — t         j                  }t        j                  «       j	                  d«      }t        j                  «       j                  d| «       |rt         j                  }| j                  j                  |«       y)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£   rÍ   ÚCHAT_SEPARATE_HISTORIES_OFFrn   rÏ   )r   r~   rÐ   rÑ   ÚroomHistoriess        r   rŠ   zChat.toggleMessageHistories  si   € ô ×2Ñ2ˆÜ(×3Ñ3Ó5×@Ñ@ÐATÓUˆÜ×#Ñ#Ó%×0Ñ0Ð1DÈ-ÐFWÔXÙÜ×7Ñ7ˆDØ�‰×#Ñ# DÔ)àr   Nc                 óò  — 	 | j                   j                  |j                  «      }| j                  |dz   z
  }d\  }}t        j                  «       j                  d«      rQ| j                  t        j                  «       j                  «       «      }|r<|j                  |«      }|j                  }n| j                  j                  |«      \  }}|r|r| j                  ||d«       yyy# t        $ r Y ŒÎw xY w)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)rp   ÚindexÚevent_stringr`   rQ   r   r¢   r£   ÚgetConversationr   Úget_locus_of_focusrE   r:   rw   rX   ÚutterMessage)r   r~   rÐ   rÜ   rD   rB   ÚchatRoomNamerU   s           r   rŒ   zChat.readPreviousMessage  sî   € ð	Ø×$Ñ$×*Ñ*¨:×+BÑ+BÓCˆEð ×.Ñ.°%¸!±)Ñ<ˆØ *Ñˆ�ä×&Ñ&Ó(×3Ñ3Ð4GÔHØ×/Ñ/´×0HÑ0HÓ0J×0]Ñ0]Ó0_Ó`ˆLÙØ&×4Ñ4°]ÓC�Ø+×0Ñ0‘ð ×&Ñ&×;Ñ;¸MÓJñ "ˆG�\ñ ‘|Ø×Ñ˜l¨G°TÕ:ð $ˆ7øô ò 	Ùð	ús   ‚%C* Ã*	C6Ã5C6c                 ó˜  — t        j                  «       j                  | j                  j                  d«      }t        j                  «       j                  «       }|j                  | j                  j                  k7  r|t        j                  k(  ry|s|t        j                  k(  ryd}|rKt        j                  «       j                  | j                  j                  d«      rt        j                  |z  }t        j                  s'| j                  j                  j                  ||«      }n&| j                  j                  j                  ||«      }t!        |j#                  «       «      rC| j                  j$                  j'                  |¬«      }| j                  j)                  ||¬«       | j                  j+                  |«       y)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   r¢   ÚgetAppSettingrn   rº   r   ÚgetActiveScriptr:   r   r»   r·   r
   ÚCHAT_MESSAGE_FROM_ROOMÚpresentChatRoomLastÚ	utilitiesÚappendStringr\   ÚstripÚspeechGeneratorræ   ÚspeakMessageÚdisplayBrailleMessage)r   rá   rB   ÚfocusedrÉ   r~   Útextræ   s           r   rà   zChat.utterMessage9  sO  € ô %×/Ñ/Ó1×?Ñ?Ø�L‰L×ÑÐ4ó6ˆ	ä×*Ñ*Ó,×<Ñ<Ó>ˆØ�;‰;˜$Ÿ,™,×+Ñ+Ò+ØœH×>Ñ>Ò>ØÙ˜Y¬(×*MÑ*MÒMØàˆÙÜ×&Ñ&Ó(×6Ñ6°t·|±|×7GÑ7GÐI\Ô]Ü×2Ñ2°\ÑAˆDä×+Ò+Ø—<‘<×)Ñ)×6Ñ6°t¸WÓE‰Dà—<‘<×)Ñ)×6Ñ6°wÀÓEˆDäˆt�z‰z‹|ÔØ—L‘L×0Ñ0×6Ñ6¸dÐ6ÓCˆEØ�L‰L×%Ñ% d°%Ð%Ô8Ø�‰×*Ñ*¨4Õ0r   c                 ó   — |j                   S )ay  Get 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   Úevents     r   ÚgetMessageFromEventzChat.getMessageFromEvent_  s   € ð �~‰~Ðr   c                 óÖ  — |r'|j                   j                  d«      r|j                  sy| j                  |j                  «      ry| j                  |j                  «      ry| j                  |«      r| j                  ||j                  «       y| j                  |j                  «      rÝ| j                  |j                  «      r2| j                  |j                  «      }t        ||j                  «      }n'| j                  |j                  «      }|j                  }| j                  |«      j                  d«      }|r| j!                  ||«       | j#                  |j                  «      }|rd}|r| j%                  |||«       y| j'                  |«      rP|j                  }| j(                  j*                  j-                  |¬«      }| j(                  j/                  ||¬«       yy)aS  Gives 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.
        zobject:text-changed:insertFTú
r/   rã   rå   )ÚtypeÚ
startswithrô   ÚisGenericTextObjectÚsourceÚisInBuddyListÚisTypingStatusChangedEventÚpresentTypingStatusChangeÚisChatRoomMsgÚisNewConversationÚgetChatRoomNamer7   rÞ   r:   r÷   rí   ÚaddMessageToHistoryÚisFocusedChatrà   ÚisAutoCompletedTextEventrn   rî   ræ   rï   )r   rö   r:   rU   rB   rñ   rò   ræ   s           r   ÚpresentInsertedTextzChat.presentInsertedTextl  s“  € ñ Ø—*‘*×'Ñ'Ð(DÔEØ—.’.Øà×#Ñ# E§L¡LÔ1ð à×Ñ §¡Ô-ð à×,Ñ,¨UÔ3Ø×*Ñ*¨5°%·.±.ÔAØà×Ñ §¡Ô-Ø×%Ñ% e§l¡lÔ3Ø×+Ñ+¨E¯L©LÓ9�Ü+¨D°%·,±,Ó?‘à#×3Ñ3°E·L±LÓA�Ø#×(Ñ(�Ø×.Ñ.¨uÓ5×;Ñ;¸DÓAˆGÙØ×(Ñ(¨°,Ô?ð
 ×(Ñ(¨¯©Ó6ˆGÙØ�ÙØ×!Ñ! $¨°Ô9Øà×*Ñ*¨5Ô1Ø—>‘>ˆDØ—L‘L×0Ñ0×6Ñ6¸dÐ6ÓCˆEØ�L‰L×%Ñ% d°%Ð%Ô8Øàr   c                 óT  — t        j                  «       j                  d«      r…| j                  |j                  «      }|rh||j                  «       k7  rU| j                  j                  j                  |¬«      }| j                  j                  ||¬«       |j                  |«       yy)aC  Presents 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ý   rH   rn   rî   ræ   rï   rK   )r   rö   rJ   rU   ræ   s        r   r   zChat.presentTypingStatusChange­  s‹   € ô ×&Ñ&Ó(×3Ñ3Ð4MÔNØ×/Ñ/°·±Ó=ˆLÙ ¨<×+GÑ+GÓ+IÒ!IØŸ™×4Ñ4×:Ñ:À&Ð:ÓI�Ø—‘×)Ñ)¨&¸Ð)Ô>Ø×,Ñ,¨VÔ4Øàr   c                 ó^   — |j                  |«       | j                  j                  ||«       y)aQ  Adds 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)r?   rw   )r   rB   rU   s      r   r  zChat.addMessageToHistoryÂ  s(   € ð 	×Ñ Ô(Ø×Ñ×)Ñ)¨'°<Õ@r   c                 óZ   — t        j                  |«      xr t        j                  |«      S )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.
        )r   Úis_editableÚis_single_line©r   Úobjs     r   rü   zChat.isGenericTextObjectÖ  s%   € ô ×&Ñ& sÓ+ÒO´×0JÑ0JÈ3Ó0OÐOr   c                 ó|   — |€y| j                   D ]*  }| j                  j                  j                  ||«      sŒ* y y)ay  Returns 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
        FT)ro   rn   rë   ÚhasMatchingHierarchy)r   r  ÚroleLists      r   ÚisBuddyListzChat.isBuddyListà  sC   € ð ˆ;Øà×1Ñ1ò 	ˆHØ�|‰|×%Ñ%×:Ñ:¸3ÀÕIÙð	ð r   c                 ó²   ‡— |r| j                  |«      ry| j                  D ]3  }|d   Št        j                  |ˆfd„«      }| j                  |«      sŒ3 y y)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.
        Tr   c                 ó4   •— t        j                  | «      ‰k(  S r$   )r   Úget_role)r!   Úroles    €r   ú<lambda>z$Chat.isInBuddyList.<locals>.<lambda>  s   ø€ ¼h×>OÑ>OÐPQÓ>RÐVZÑ>Z€ r   F)r  ro   r   Úfind_ancestor)r   r  ÚincludeListr  Ú	candidater  s        @r   rþ   zChat.isInBuddyListô  s_   ø€ ñ ˜4×+Ñ+¨CÔ0Øà×1Ñ1ò 	ˆHØ˜A‘;ˆDÜ ×.Ñ.¨sÓ4ZÓ[ˆIØ×Ñ 	Õ*Ùð		ð r   c                 ó\   — | j                  |«      }| j                  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Þ   rw   rS   )r   r  rU   s      r   r  zChat.isNewConversation  s.   € ð ×+Ñ+¨CÓ0ˆØ×)Ñ)×9Ñ9¸,ÓGÐGÐGr   c                 ó6  — |syd}t        j                  |«      st        j                  |«      r&t        j                  |«      r| j                  |«      }| j                  j                  D ]+  }|r||j                  k(  sŒ|c S ||j                  k(  sŒ)|c S  y)zºAttempts to locate the conversation associated with obj.

        Arguments:
        - obj: the accessible of interest

        Returns the conversation if found; None otherwise
        Nr/   )
r   Úis_textr   Úis_entryr  r  rw   rO   r:   r;   )r   r  r:   rU   s       r   rÞ   zChat.getConversation  s—   € ñ Øàˆô ×Ñ Ô$¬×(9Ñ(9¸#Ô(>Ü×&Ñ& sÔ+Ø×'Ñ'¨Ó,ˆDà ×2Ñ2×@Ñ@ò 	$ˆLÙØ˜<×,Ñ,Ó,Ø'Ò'ð ˜×/Ñ/Ó/Ø#Ò#ð	$ð r   c                 óØ   — t        j                  |«      rUt        j                  t        j                  |«      «      r-t        j
                  |«       xr t        j                  |«      S y)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.
        F)r   r  Úis_scroll_paner   Ú
get_parentr  Úis_multi_liner  s     r   r  zChat.isChatRoomMsg8  sS   € ô ×Ñ˜sÔ#¬×(BÑ(BÄ8×CVÑCVÐWZÓC[Ô(\Ü"×.Ñ.¨sÓ3Ð3ÒV¼×8QÑ8QÐRUÓ8VÐVØr   c                 ó&  — t        j                  |«      rR| j                  j                  j	                  |«      }d|d|g}t        j                  t
        j                  |d«       |S d|dg}t        j                  t
        j                  |d«       y)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:z's window is focused chat:Tz!is not focused chat (not showing)F)r   Ú
is_showingrn   rë   Ú topLevelObjectIsActiveAndCurrentr   ÚprintTokensÚ
LEVEL_INFO)r   r  ÚactiveÚtokenss       r   r  zChat.isFocusedChatD  s€   € ô ×!Ñ! #Ô&Ø—\‘\×+Ñ+×LÑLÈSÓQˆFØ˜sÐ$@À&ÐIˆFÜ×Ñœe×.Ñ.°¸Ô=ØˆMà˜3Ð CÐDˆÜ×Ñœ%×*Ñ*¨F°DÔ9Ør   c                 ó®  — d„ }t        j                  ||«      }d}	 | j                  j                  j	                  |«      }|j                  «       j                  «       | j                  j                  j                  «       j                  «       k7  r|}|sŸt        j                  |t        j                  «      }	 | j                  j                  j	                  |«      }|j                  «       j                  «       | j                  j                  j                  «       j                  «       k7  r|}|S |S # t        $ r Y Œ®w xY w# t        $ r Y |S w xY w)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.
        c                 óZ   — t        j                  | «      xs t        j                  | «      S r$   )r   Úis_page_tabÚis_frame)r!   s    r   Úpredz"Chat.getChatRoomName.<locals>.prede  s#   € Ü×*Ñ*¨1Ó-ÒH´×1EÑ1EÀaÓ1HÐHr   r/   )r   r  rn   rë   ÚdisplayedTextÚlowerrí   r:   r`   r   r-  )r   r  r.  Úancestorr:   rò   s         r   r  zChat.getChatRoomNameW  s#  € ò	Iô ×)Ñ)¨#¨tÓ4ˆØˆð	Ø—<‘<×)Ñ)×7Ñ7¸ÓAˆDØ�z‰z‹|×!Ñ!Ó# t§|¡|×'8Ñ'8×'>Ñ'>Ó'@×'FÑ'FÓ'HÒHØ�ñ Ü×-Ñ-¨c´;×3GÑ3GÓHˆHðØ—|‘|×-Ñ-×;Ñ;¸HÓE�Ø—:‘:“<×%Ñ%Ó'¨4¯<©<×+<Ñ+<×+BÑ+BÓ+D×+JÑ+JÓ+LÒLØ�Dð ˆˆtˆøô! ò 	Ùð	ûô ò Øàˆðús%   �A8D8 Â<A8E Ä8	EÅEÅ	EÅEc                 óÔ   — t        j                  |j                  «      sy| j                  j                  j                  «       \  }}|dk(  r|j                  r|j                  dk7  ryy)z”Returns True if event is associated with text being autocompleted.

        Arguments:
        - event: the accessible event being examined
        FÚTabú	T)r   r  rý   rn   rë   ÚlastKeyAndModifiersrô   )r   rö   ÚlastKeyÚmodss       r   r  zChat.isAutoCompletedTextEvent€  sT   € ô ×"Ñ" 5§<¡<Ô0ØàŸ™×.Ñ.×BÑBÓD‰ˆ�Ø�eÒ §¢°5·>±>ÀTÒ3IØàr   c                  ó   — y)z•Returns True if event is associated with a change in typing status.

        Arguments:
        - event: the accessible event being examined
        Fr5   rõ   s     r   rÿ   zChat.isTypingStatusChangedEvent�  s   € ð r   r   )T)r2   r3   r4   Ú__doc__r   rt   ru   rÆ   rÊ   r†   rˆ   rŠ   rŒ   rà   r÷   r  r   r  rü   r  rþ   r  rÞ   r  r  r  r  rÿ   r5   r   r   rc   rc     s‹   „ ñò()òTò4&òPAòF
ò.ò$ò$ó";ó@$1òLò?òBò*Aò(Pòó(ò(	Hò#òJ
òò&'òRó r   rc   N)r9  Ú__id__Ú__version__Ú__date__Ú__copyright__Ú__license__r/   r   r   r   r   r   r	   r
   r   r   r   Ú	ax_objectr   Úax_utilitiesr   r   r7   rM   rc   r5   r   r   ú<module>rA     sx   ðñ( 'à	€Ø€Ø€Ø7€Ø€å Ý Ý Ý Ý Ý Ý Ý Ý Ý Ý Ý %÷!&ñ !&÷RE$ñ E$÷Ziñ i÷bC
ò C
r   