+
    QDbm  c                   s    ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ]! RR7       RtRtRtR	t ! R
 R4      tR# )    N)
debugprint)DBusGMainLoop)reduceT)Zset_as_defaultz#org.opensuse.CupsPkHelper.MechanismZ/z1org.opensuse.CupsPkHelper.Mechanism.NotPrivilegedc                   s   a  ] tR t^4t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R  t#R! t$R" t%R# t&R$ t'R%t(V t)R&# )'
Connectionc                s@   R V n          \        P                  ! 4       V n        \        P                  ! 4       V n        \        P                  ! VVVR7      V n
        V P                  4        R #   \        P                  P                   d    R ;T n        T n         L_i ; i)N)hostport
encryption)_parentdbusZ
SessionBus_session_busZ	SystemBus_system_bus
exceptionsDBusExceptioncupsr   _connection_hack_subclass)selfr   r   r   s   &&&&*/usr/share/system-config-printer/cupspk.py__init__ZConnection.__init__5   s    	8 $ 1D#~~/D
  ??046@B 	 ,, 	8377D 0	8s   4A- --BBc                s>   \        V P                  P                  4      p\        V P                  4       Fd  pV^ ,          R8X  d   K  \	        V P                  V4      p\        V4      V8w  d   K;  \        W4      '       d   KN  \        WVP                  4       Kf  	  R# )r    Z_N)typer   ZgetPrintersdirZgetattrZhasattrZsetattrZ__call__)r   Z
methodtypeZfnameZfns   &   r   r   ZConnection._hack_subclassF   sw     $**667
))*EQx3))51BBx:%4''R[[1 +    c                s    Wn         R # N)r   )r   Zparent   &&r   
set_parentZConnection.set_parentT   s    r   c                s     V P                   P                  \        \        4      p\        P
                  ! V\        4      #   \        P                  P                   d     R # \         d     R # i ; ir   )
r   Z
get_objectCUPS_PK_NAMECUPS_PK_PATHr	   Z	InterfaceCUPS_PK_IFACEr   r   ZAttributeError)r   Zobjects   & r   _get_cups_pkZConnection._get_cups_pkX   sW    	%%00|LF>>&-88,, 	 		s   >A A1#A1,A10A1c                s   R pVP                  RR 4      pV'       g+   V P                  4       p	V	'       d    V	P                  V4      pV'       g	   V'       g	   V! V/ VB # Rp
  V! VRV/ p
\        V
4      \        8X  d3   V
R,          pV
^ ,          R8X  d   \        V4      ^8X  d
   V^ ,          # V#  T
R8w  d%   \        RT: R\!        T
4      : 24       T! T/ TB # R #   \        P                  P
                   d     Li ; i  \        P                  P
                   dj   pTP                  4       \        8X  dF   \        RTP                  4       ,          4       \        P                  ! \        P                  R4      h R p?K  R p?ii ; i)	NZ	signaturezPolicyKit communication issue:i   NN zDBus exception: %sZpkcancelzPolicyKit call to z did not work: )Zpopr   Zget_dbus_methodr	   r   r   r   tuplelenZget_dbus_nameCUPS_PK_NEED_AUTHr   Zget_dbus_messager   ZIPPErrorZIPP_NOT_AUTHORIZEDZrepr)r   Zuse_fallbackZpk_function_namepk_argsZfallback_functionargskwdsZpk_functionZdbus_args_signatureZcups_pkZ	pk_retvalretvalZes   &&&&&*,      r   _call_with_pk_and_fallbackZ%Connection._call_with_pk_and_fallbackd   sk   "hh{D9'')G")"9"9:J"KK {$d3d333	'R>QR	 	?e+&r]F !|r) v;!+#)!9,#)M ?)4+;= >$d3d33 I 44 6 ??00 ??$(99 4q7I7I7L LM--(?(?LLs1   C #AD /D D DF#AFFc                sl   R .p\        V4      \        V4      8w  d"   RV^ &   VP                  V4       \        V4      # R p\        \        V4      4       EF  p\	        W%,          4      W,          8w  Ed   W,          \
        8X  d=   \	        W%,          4      \        8X  d#   VP                  \        W%,          4      4       Kn  W,          \
        8X  d=   \	        W%,          4      \        8X  d#   VP                  \        W%,          4      4       K  W,          \
        8X  d>   \	        W%,          4      \        8X  d$   VP                  \        W%,          4      4       EK	  W,          \
        8X  d   W%,          f   VP                  R4       EK8  W,          \        8X  d>   \	        W%,          4      \        8X  d$   VP                  \        W%,          4      4       EK  W,          \        8X  d   W%,          f   VP                  . 4       EK  RpVP                  W%,          4       EK  	  WC^ &   \        V4      # )FTr   )r    Zextendr   Zranger   strintappendZfloatboollist)r   Ztypesr#   r%   Z	exceptionis   &&*   r   _args_to_tupleZConnection._args_to_tuple   sp   u:T"F1IMM% <	s5z"ADG}(8s?tDG}';MM#dg,/X_dg%)?MM#dg,/X_dg$)>MM#dg,/X_MM"%X%$tw-5*@MM$tw-0X%$'/MM"% $IMM$'"9 #< q	V}r   c                s    . pV F3  pWB9   d   VP                  W$,          4       K"  VP                  R 4       K5  	  \        V4      # )r   )r)   r   )r   Znamesr$   Zretnames   &&,  r   _kwds_to_varsZConnection._kwds_to_vars   s;    D|

4:&

2	  Szr   c                s6   R p^ p. p. p^ p\        V4      ^8X  d.   V P                  ! \        \        \        \        ..VO5!  w  r4rVpM@RV9   d
   VR,          pRV9   d
   VR,          pRV9   d
   VR,          pRV9   d
   VR,          pWtWV3p V P                  ! VRVV P
                  P                  .VO5/ VB p	\        V	P                  4       4      ^ 8  d<   \        V	\        V	P                  4       4      ^ ,          ,          4      \        8X  d   V	# / p
V	e_   V	P                  4        FJ  p\        V4      \        P                  8X  d    \        W,          4      V
\        V4      &   K@  W,          W&   KL  	  / p^ pR\        V4      ,           pV
P                  4        Uu. uF  qP!                  V4      '       g   K  VNK  	  pp\        V4      ^ 8  d   Rp/ pV F=  pVR\        V4      \        V4      ,
           pVR8w  d   W,          VV&   K5  W,          pK?  	  Ve   VVV&   V^,          pR\        V4      ,           pV
P                  4        Uu. uF  qP!                  V4      '       g   K  VNK  	  ppK  V#   \         d    \        R4       RT9   d   Rp\        T4      ^ 8  d   \        R T4      pMR	p\        T4      ^ 8  d   \        R
 T4      pMR	pYET3pT P                  ! TRTT P
                  P                  .TO5/ TB p	 ELSi ; iu upi u upi )Ftimeoutlimitinclude_schemesexclude_schemesZ
DevicesGetz-DevicesGet API exception; using old signatureTc                 "    V R ,           V,           # Z, xZyr   r   <lambda>'Connection.getDevices.<locals>.<lambda>       q3w{r   r   c                 r4   r5   r6   r7   r   r   r9   r:     r;   r   NZ:z
device-uri)r    r-   r(   r'   r&   r   
getDevices	TypeErrorr   r   keysr   r+   dictr	   StringZendswith)r   r#   r$   
use_pycupsr1   r2   r3   r0   r"   resultZ
result_strr,   ZdevicesZnZpostfixr8   Zdevice_keysZ
device_uriZdevice_dictZkeys   &*,                 r   r<   ZConnection.getDevices   s   
t9>MQM`M`begjloqtauM}x|M}JZ'D y/$W D("&'8"9 D("&'8"9?D	D44Z5A7595E5E5P5PD 7;D ?CDF: "tVD4G4J-K'LPT'T]
[[]7dkk)),VYJs1v&$*IJM	 # Q-",//"3K"3Qzz'7Jqq"3K;!#JK .Q#g,./,&'1}K$!+J ! %&1
#FACGmG&0oo&7O&7::g;N11&7KOK{  	DGHD !
 O$q("(*B*9#; #%O$q("(*B*9#; #%?G44Z5A7595E5E5P5PD 7;D ?CDF'	DT L" Ps+   -I: L<LL.L:BLLc                    V P                   ! \        ..VO5!  w  r4V3pV P                  ! VR VV P                  P                  .VO5/ VB  R# )Z	JobCancelN)r-   r(   r&   r   	cancelJobr   r#   r$   rA   jobidr"      &*,   r   rD   ZConnection.cancelJob;  s[    "113%?$?)''
(3W(,(8(8(B(B	7 *.	7 26	7r   c                    V P                   ! \        \        ..VO5!  w  r4pWE3pV P                  ! VR VV P                  P
                  .VO5/ VB  R# )ZJobSetHoldUntilN)r-   r(   r'   r&   r   setJobHoldUntil)r   r#   r$   rA   rF   Zjob_hold_untilr"      &*,    r   rI   ZConnection.setJobHoldUntilG  s`    .2.A.A3*.Tt.T+N+''
(97(,(8(8(H(H	7 *.	7 26	7r   c                rC   )Z
JobRestartN)r-   r(   r&   r   
restartJobrE   rG   r   rK   ZConnection.restartJobP  s[    "113%?$?)''
(4g(,(8(8(C(C	7 *.	7 26	7r   c                s
   RpRp\        V4      ^8X  d#   V P                  ! \        \        ..VO5!  w  rVpMbV P                  ! \        ..VO5!  w  rVRV9   d   VR,          pM6RV9   d   VR,          pM%RV9   d   VR,          pMV'       g   \        4       hRpV'       Eg   Vf   VEe   \        P
                  ! RR7      w  r\        P                  ! V4       Wi3p
V P                  ! VRV
V P                  P                  .VO5/ VB  \        P                  ! V	\        P                  4      p\        P                  ! VR4      pVP                  ^ 4       Vev   \        P                  ! V^ \        P                   4       VP#                  4       pVR	8w  d8   \        P$                  ! WLP'                  R
4      4       VP#                  4       pK>  MZVP                  ^ 4       VP#                  4       pVR	8w  d3   VP%                  VP'                  R
4      4       VP#                  4       pK9  VP                  4        \        P(                  ! V	4       R# VX3p
V P                  ! VRV
V P                  P                  .VO5/ VB  R# )a  Keeping this as an alternative for the code.
We don't use it because it's not possible to know if the call was a
PK-one (and so we push the content of a temporary filename to fd or
file) or a non-PK-one (in which case nothing should be done).

    filename = None
    fd = None
    file = None
    if use_pycups:
        if len(kwds) != 1:
            use_pycups = True
        elif kwds.has_key('filename'):
            filename = kwds['filename']
        elif kwds.has_key('fd'):
            fd = kwds['fd']
        elif kwds.has_key('file'):
            file = kwds['file']
        else:
            use_pycups = True

        if fd or file:
Nfilenamefdfilez/tmp)r   ZFileGetZrtr   zUTF-8)r    r-   r'   r=   tempfilemkstemposcloser&   r   getFileZopenZO_RDONLYZfdopenseeklseekSEEK_SETreadlinewriteZencoderemove)r   r#   r$   file_objectrM   rA   resourcerL   tmpfdtmpfnamer"   Ztmpfileline   &*,          r   rS   ZConnection.getFileY  s-   0 t9>/3/B/BC:/UPT/U,Z8%)%8%8#%F%F"ZT!
+$Z4"6l!#+%#H
;3J !) 0 0V <UHHe*G++J,5w,0,<,<,D,D; .2; 6:;
 GGXr{{3Eii-GLL!~"a-'')bjHHb++g"67"++-D !   !$'')bj%%t{{7';<"++-DMMIIx *G++J,5w,0,<,<,D,D; .2; 6:;r   c                s   \        V4      ^8X  d#   V P                  ! \        \        ..VO5!  w  r4pMbV P                  ! \        ..VO5!  w  r4RV9   d   VR,          pM6RV9   d   VR,          pM%RV9   d   VR,          pMV'       g   \        4       hRpV'       Egt   Xf   XEek   \        P
                  ! 4       w  r\        P                  ! V^ \        P                  4       Ve|   \        P                  ! V^ \        P                  4       \        P                  ! VR4      p
V
R8w  d7   V
R8w  d0   \        P                  ! W4       \        P                  ! VR4      p
K=  MPXP                  ^ 4       VP                  4       pVR8w  d)   \        P                  ! W4       VP                  4       pK/  \        P                  ! V4       WI3pV P                  ! VRVV P                  P                   .VO5/ VB  \        P"                  ! V	4       R# VX3pV P                  ! VRVV P                  P                   .VO5/ VB  R# )	i   rL   rM   rN   Ni   r   r   ZFilePut)r    r-   r'   r=   rO   rP   rQ   rU   rV   ZreadrX   rT   rW   rR   r&   r   putFilerY   )r   r#   r$   rA   r[   rL   rM   rZ   r\   r]   Zbufr^   r"   r_   r   r`   ZConnection.putFile  s   t9>/3/B/BC:/UPT/U,Z8%)%8%8#%F%F"ZT!
+$Z4"6l!#+%#H
;3J ( 0 0 2UHHeQ,~"a-ggr3'RiC3JHHe)''2s+C  !$"++.bjHHe*&//2DHHe*G++J,5w,0,<,<,D,D; .2; 6:;
 IIx   *G++J,5w,0,<,<,D,D; .2; 6:;r   c                sR   V P                   ! \        ..VO5!  w  r4V P                  ! . RO3/ VB w  rVrxrRpV'       gS   V'       gK   V
'       dC   \        P                  ! RR7      w  rV
P                  V4       \        P                  ! V4       RpV'       d]   V'       gU   WIWWV3pV P                  ! VRVV P                  P                  .VO5/ VB  V'       d   \        P                  ! V4       R# R# WIWgV3pV P                  ! VRVV P                  P                  .VO5/ VB  R# )rL   FT)ZtextZPrinterAddWithPpdFileZ
PrinterAddN)rL   ppdnameinfolocationdeviceppd)r-   r'   r/   rO   rP   ZwriteFdrQ   rR   r&   r   
addPrinterZunlink)r   r#   r$   rA   r.   rL   ra   rb   rc   rd   re   Zneed_unlinkrM   r"   s   &*,           r   rf   ZConnection.addPrinter  s&   !00#>>;?;M;M  OK  <T  OS  <T8DFxC%--D9NRKKOHHRLKGXX>G++J,CW,0,<,<,G,G; .2; 6:; 		(#  WH=G++J,8',0,<,<,G,G; .2; 6:;r   c                    V P                   ! \        \        ..VO5!  w  r4pWE3pV P                  ! VR VV P                  P                  .VO5/ VB  R# )ZPrinterSetDeviceN)r-   r'   r&   r   setPrinterDevice)r   r#   r$   rA   r.   rd   r"   rJ   r   rh   ZConnection.setPrinterDevice  s_    %)%8%8#s%Kd%K"6.''
(:G(,(8(8(I(I	7 *.	7 26	7r   c                rg   )ZPrinterSetInfoN)r-   r'   r&   r   setPrinterInfo)r   r#   r$   rA   r.   rb   r"   rJ   r   ri   ZConnection.setPrinterInfo  s_    #'#6#6Sz#ID#I 4,''
(8'(,(8(8(G(G	7 *.	7 26	7r   c                rg   )ZPrinterSetLocationN)r-   r'   r&   r   setPrinterLocation)r   r#   r$   rA   r.   rc   r"   rJ   r   rj   ZConnection.setPrinterLocation  s`    '+':':C:'M'M$8"''
(<g(,(8(8(K(K	7 *.	7 26	7r   c                rH   )ZPrinterSetSharedN)r-   r'   r*   r&   r   setPrinterShared)r   r#   r$   rA   r.   Zsharedr"   rJ   r   rk   ZConnection.setPrinterShared  s_    %)%8%8#t%Lt%L"6.''
(:G(,(8(8(I(I	7 *.	7 26	7r   c                s    V P                   ! \        \        \        ..VO5!  w  r4rVWEV3pV P                  ! VR VV P                  P                  .VO5/ VB  R# )ZPrinterSetJobSheetsN)r-   r'   r&   r   setPrinterJobSheets)r   r#   r$   rA   r.   ZstartZendr"      &*,     r   rl   ZConnection.setPrinterJobSheets$  sd    )-)<)<c3_)Tt)T&5$''
(=w(,(8(8(L(L	7 *.	7 26	7r   c                rg   )ZPrinterSetErrorPolicyN)r-   r'   r&   r   setPrinterErrorPolicyr   r#   r$   rA   r.   Zpolicyr"   rJ   r   rn   Z Connection.setPrinterErrorPolicy.  s_    %)%8%8#s%Kd%K"6.''
(?(,(8(8(N(N	7 *.	7 26	7r   c                rg   )ZPrinterSetOpPolicyN)r-   r'   r&   r   setPrinterOpPolicyro   rJ   r   rp   ZConnection.setPrinterOpPolicy8  s_    %)%8%8#s%Kd%K"6.''
(<g(,(8(8(K(K	7 *.	7 26	7r   c                rH   )ZPrinterSetUsersAllowedN)r-   r'   r+   r&   r   setPrinterUsersAllowedr   r#   r$   rA   r.   Zusersr"   rJ   r   rq   Z!Connection.setPrinterUsersAllowedB  s_    $($7$7d$Kd$K!5-''
(@'(,(8(8(O(O	7 *.	7 26	7r   c                rH   )ZPrinterSetUsersDeniedN)r-   r'   r+   r&   r   setPrinterUsersDeniedrr   rJ   r   rs   Z Connection.setPrinterUsersDeniedL  s_    $($7$7d$Kd$K!5-''
(?(,(8(8(N(N	7 *.	7 26	7r   c                s   V P                   ! \        \        \        ..VO5!  w  r4rVV'       g   V3pM&V P                   ! \        \        \        ..VO5!  w  r4rWWEV3pV P                  ! VR VV P                  P
                  .VO5/ VB  R# )ZPrinterAddOptionDefaultN)r-   r'   r+   r&   r   addPrinterOptionDefault)	r   r#   r$   rA   r.   optionZvalueZvaluesr"   s	   &*,      r   rt   Z"Connection.addPrinterOptionDefaultU  s     -1,?,?c3,WRV,W)6XF 261D1Dc3PTEU1]X\1].Zv(''
(A7(,(8(8(P(P	7 *.	7 26	7r   c                rg   )ZPrinterDeleteOptionDefaultN)r-   r'   r&   r   deletePrinterOptionDefault)r   r#   r$   rA   r.   ru   r"   rJ   r   rv   Z%Connection.deletePrinterOptionDefaultg  s_    %)%8%8#s%Kd%K"6.''
(Dg(,(8(8(S(S	7 *.	7 26	7r   c                rC   )ZPrinterDeleteN)r-   r'   r&   r   deletePrinterr   r#   r$   rA   r.   r"   rG   r   rw   ZConnection.deletePrinterq  s[    !00#>>'''
(7(,(8(8(F(F	7 *.	7 26	7r   c                    V P                   ! \        \        ..VO5!  w  r4pWT3pV P                  ! VR VV P                  P                  .VO5/ VB  R# )ZClassAddPrinterN)r-   r'   r&   r   addPrinterToClassr   r#   r$   rA   Zprinterr.   r"   rJ   r   rz   ZConnection.addPrinterToClass|  s_    &*&9&93*&Lt&L#d/''
(97(,(8(8(J(J	7 *.	7 26	7r   c                ry   )ZClassDeletePrinterN)r-   r'   r&   r   deletePrinterFromClassr{   rJ   r   r|   Z!Connection.deletePrinterFromClass  s_    &*&9&93*&Lt&L#d/''
(<g(,(8(8(O(O	7 *.	7 26	7r   c                rC   )ZClassDeleteN)r-   r'   r&   r   deleteClassrx   rG   r   r}   ZConnection.deleteClass  s[    !00#>>'''
(5w(,(8(8(D(D	7 *.	7 26	7r   c                rC   )ZPrinterSetDefaultN)r-   r'   r&   r   
setDefaultrx   rG   r   r~   ZConnection.setDefault  s[    !00#>>'''
(;W(,(8(8(C(C	7 *.	7 26	7r   c                    V P                   ! \        ..VO5!  w  r4VR 3pV P                  ! VRVV P                  P                  .VO5/ VB  R# )TPrinterSetEnabledN)r-   r'   r&   r   enablePrinterrx   rG   r   r   ZConnection.enablePrinter  s]    !00#>>,''
(;W(,(8(8(F(F	7 *.	7 26	7r   c                r   )Fr   N)r-   r'   r&   r   disablePrinterrx   rG   r   r   ZConnection.disablePrinter  s]    !00#>>-''
(;W(,(8(8(G(G	7 *.	7 26	7r   c                s    V P                   ! \        ..VO5!  w  r4VR R3pV P                  ! VRVV P                  P                  .VO5/ VB  R# )Tr   PrinterSetAcceptJobsN)r-   r'   r&   r   
acceptJobsrx   rG   r   r   ZConnection.acceptJobs  s`    !00#>>r"''
(>(,(8(8(C(C	7 *.	7 26	7r   c                s    V P                   ! \        ..VO5!  w  r4V P                  ! R .3/ VB w  pVRV3pV P                  ! VRVV P                  P
                  .VO5/ VB  R# )reasonFr   N)r-   r'   r/   r&   r   
rejectJobs)r   r#   r$   rA   r.   r   r"   rJ   r   r   ZConnection.rejectJobs  sy    !00#>>&&z:T:	'''
(>(,(8(8(C(C	7 *.	7 26	7r   c                s0   R pRpV P                   ! VRVV P                  P                  .VO5/ VB p/ pVe_   VP                  4        FJ  p\	        V4      \
        P                  8X  d    \        WW,          4      V\        V4      &   K@  WW,          Wg&   KL  	  V# )FZServerGetSettingsr6   )r&   r   adminGetServerSettingsr>   r   r	   r@   r'   )r   r#   r$   rA   r"   rB   settingsr,   rm   r   r   Z!Connection.adminGetServerSettings  s    
00/BG/3/?/?/V/V> 15> 9=> [[]7dkk)'*69~HSV$"()HK	 # r   c                rC   )ZServerSetSettingsN)r-   r?   r&   r   adminSetServerSettings)r   r#   r$   rA   r   r"   rG   r   r   Z!Connection.adminSetServerSettings  s[    !%!4!4dV!Cd!C+''
(;W(,(8(8(O(O	7 *.	7 26	7r   )r   r   r
   r   N)*Z__name__Z
__module__Z__qualname__Z__firstlineno__r   r   r   r   r&   r-   r/   r<   rD   rI   rK   rS   r`   rf   rh   ri   rj   rk   rl   rn   rp   rq   rs   rt   rv   rw   rz   r|   r}   r~   r   r   r   r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r   4   s     "2	14h+\	([B777O;d3;l;67777777777$7777777777&7 7r   r   )rQ   ZsysrO   r   r	   Zdebugr   Zdbus.mainloop.glibr   Z	functoolsr   r   r   r   r!   r   r6   r   r   <module>r      sH   : 
 
     ,  T "55G w
7 w
7r   