
    Egh                     l    d dl mZmZmZ d dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZ  G d de
e      Zy)    )GioGLibCScreensaverN)
BaseClient)LoginInterface)DEBUGc                   F     e Zd ZdZdZdZ fdZd Zd	dZd	dZ	d Z
 xZS )
LogindClientz
    A client for communicating with logind.  At startup we check
    for its availability, falling back to ConsoleKit if it's not
    available.
    zorg.freedesktop.login1z/org/freedesktop/login1c                     t         t        |   t        j                  j
                  t        j                  | j                  | j                         t        j                         | _        d| _        d| _        y)z@
        We first try to connect to the logind manager.
        N)superr
   __init__r   BusTypeSYSTEMr   LogindManagerProxyLOGIND_SERVICELOGIND_PATHosgetpidpidsession_pathsession_proxy)self	__class__s    9/usr/share/cinnamon-screensaver/dbusdepot/logindClient.pyr   zLogindClient.__init__   sZ     	lD*3;;+=+=+7+J+J+/+>+>+/+;+;	=
 99; !    c           	         	 t        j                         }d|z  }t        j                  |d      j	                         j                  dd      }| j                  j                  |d      | _        t        d|d|d	| j                         t        j                  j                  t         j"                  j$                  t         j&                  j(                  | j*                  | j                  d| j,                  d       y# t         j                  $ r*}t        d
|z  d       | j                          Y d}~yd}~ww xY w)z
        If our manager connection succeeds, we get the current session path and attempt
        to connect to its interface.
        z'loginctl show-user %s -pDisplay --valueT)shell
 Nz+login client: found session path for user 'z' (session_id: z): z,login client: could not get session path: %s)flush)r   get_user_name
subprocesscheck_outputdecodereplaceproxycall_get_session_syncr   r   Errorprint
on_failurer   LogindSessionProxynew_for_busr   r   r   DBusProxyFlagsNONEr   on_session_ready)r   current_usercmdcurrent_session_ides        r   on_client_setup_completez%LogindClient.on_client_setup_complete#   s   
	--/L;lJC!+!8!8D!I!P!P!R!Z!Z[_ac!d $

 @ @ASUY ZD[gi{  ~B  ~O  ~O  P  Q 	''33CKK4F4F474F4F4K4K484G4G484E4E48484I4I48	: zz 	@1DDQOO	s   BD E  D;;E c                 :    t         j                  j                  |       _         j                  j	                  d fd        j                  j	                  d fd        j                  j	                  d j
                          j                  dd       y)	z
        Once we're connected to the session interface, we can respond to signals sent from
        it - used primarily when returning from suspend, hibernation or the login screen.
        unlockc                 &    j                  d      S )Nr6   emitr&   r   s    r   <lambda>z/LogindClient.on_session_ready.<locals>.<lambda>D   s    499X;N r   lockc                 &    j                  d      S )Nr<   r8   r:   s    r   r;   z/LogindClient.on_session_ready.<locals>.<lambda>E   s    69J r   znotify::activestartup-statusTN)r   r+   new_for_bus_finishr   connecton_active_changedr9   )r   objectresultdatas   `   r   r/   zLogindClient.on_session_ready=   sy    
 *<<OOPVW""8-NO""6+JK""#3T5K5KL		"D)r   c                 ^    | j                   j                  d      r| j                  d       y y )Nactive)r   get_propertyr9   )r   r&   pspecrD   s       r   rA   zLogindClient.on_active_changedJ   s'    **84IIh 5r   c                 (    | j                  dd       y )Nr>   Fr8   )r   argss     r   r*   zLogindClient.on_failureN   s    		"E*r   )N)__name__
__module____qualname____doc__r   r   r   r4   r/   rA   r*   __classcell__)r   s   @r   r
   r
      s-    
 3N+K":4* +r   r
   )gi.repositoryr   r   r   r   r"   statusdbusdepot.baseClientr   dbusdepot.loginInterfacer   
util.utilsr   r
    r   r   <module>rV      s/    2 1 	   + 3 C+>: C+r   