+
    KiG  c                   s   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	 ^ RI
Ht ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RIH t  ^ RI!H"t" ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t( R"t) ! R R4      t* ! R R]$4      t+ ! R R]+4      t, ! R R]+4      t- ! R R]+4      t. ! R R]"4      t/ ! R R]P`                  Pb                  4      t2 ! R R ]4      t3R#R! lt4R# )$zEA App service.N)gettext)AnyDictOptional)ElementTree)Gio)settings)LutrisConfigwrite_game_config)add_gameget_game_by_field)ServiceGameCollection)Game)SERVICE_LOGINOnlineService)
sync_media)ServiceGame)ServiceMedia)logger)slugifyc                   s6   a  ] tR t^t o RtR tR tR tRtV t	R# )
EAAppGameszProgram Files/EA Gamesc                s    Wn         \        P                  P                  V P                   R V P                  4      V n        R# )drive_cN)prefix_pathospathjoinea_games_locationea_games_path)selfr      &&;/usr/lib/python3.14/site-packages/lutris/services/ea_app.py__init__ZEAAppGames.__init__    s-    &WW\\$*:*:ItG]G]^    c              #  s   "   \         P                  P                  V P                  4      '       g   R # \         P                  ! V P                  4       F  pVx  K	  	  R # 5iN)r   r   existsr   Zlistdir)r   game_folder   & r   iter_installed_gamesZEAAppGames.iter_installed_games$   s@     ww~~d0011::d&8&89K :s   AA!c                s   . pV P                  4        F  p\        P                  P                  V P                  VR 4      p\        P                  P                  V4      '       g   \        P                  ! RV4       Kl  \        P                  ! V4      pVP                  R4      P                  R4      pV'       g   \        P                  ! RV4       K  TP                  V Uu. uF  qfP                  NK  	  up4       K  	  V# u upi )z__Installer/installerdata.xmlzNo installerdata.xml for %sZ
contentIDsZ	contentIDzContent ID not found for %s)r%   r   r   r   r   r"   r   warningr   ZparseZfindZfindallappendZtext)r   Zinstalled_game_idsr#   Zinstaller_data_pathZtreeZnodesZnode   &      r   get_installed_games_content_idsZ*EAAppGames.get_installed_games_content_ids*   s    446K"$'',,t/A/A;Po"p77>>"566<kJ$$%89DIIl+33K@E<kJ%%U&CUTyyU&CD 7 "! 'Ds   %D
)r   r   N)
__name__
__module____qualname____firstlineno__r   r   r%   r)   __static_attributes____classdictcell____classdict__   @r   r   r      s      0_" "r    r   c                   sP   a  ] tR t^:t o RtR.t]t]R 4       t	V 3R lR lt
RtV tR# )
EAAppMediaea_appz%s.jpgc                s    \         P                  P                  \        P                  V P
                  V P                  4      # r!   )r   r   r   r   	CACHE_DIRservicenamer      &r   	dest_pathZEAAppMedia.dest_path?   s'    ww||H..diiHHr    c                sL   < V ^8  d   QhRS[ S[S[3,          RS[S[,          /# )   detailsZreturn)r   strr   r   Zformatr1      "r   __annotate__ZEAAppMedia.__annotate__C   s+     F FT#s(^ F Fr    c                st    VR ,          V P                   ,          R,          pVe   VP                  RR4      # R# )baseItemZlargestImageNr   )r7   get)r   r<   Zimage   && r   get_media_urlZEAAppMedia.get_media_urlC   s5    
#DII.~>*/*;uyy&EEr     N)r*   r+   r,   r-   r6   Zfile_patternsZNotImplementedr7   propertyr:   rD   r.   r/   r0   r2   r   r3   r3   :   s6     GJMDI IF Fr    r3   c                   s    ] tR t^HtRtRtRtR# )EAAppKeyArtkeyArtrE   N)i   il   r*   r+   r,   r-   r7   Zsizer.   rE   r    r   rG   rG   H   s    DDr    rG   c                   s    ] tR t^MtRtRtRtR# )EAAppPackArtpackArtrE   N)i   i   rI   rE   r    r   rJ   rJ   M   s    DDr    rJ   c                   s    ] tR t^RtRtRtRtR# )EAAppPrimaryLogoprimaryLogorE   N)i   id   rI   rE   r    r   rL   rL   R   s    DDr    rL   c                   s4   a  ] tR t^Wt o Rt]R 4       tRtV tR# )	EAAppGamer4   c                s    \        4       pVR ,          Vn        VR,          Vn        VR,          R,          Vn        \        P
                  ! V4      Vn        V# )	contentIdZgameSlugrA   Ztitle)rN   appidslugr7   jsondumpsr<   )Zclsgameea_gamerC   r   new_from_apiZEAAppGame.new_from_apiZ   sG    +[)J'J'0**T*r    rE   N)	r*   r+   r,   r-   r6   ZclassmethodrV   r.   r/   r0   r2   r   rN   rN   W   s     G r    rN   c                   s.   a  ] tR t^dt o RtRR ltRtV tR# )LegacyRenegotiationHTTPAdaptera  Allow insecure SSL/TLS protocol renegotiation in an HTTP request.

By default, OpenSSL v3 expects that servers support RFC 5746. Unfortunately,
accounts.ea.com does not support this TLS extension (from 2010!), causing
OpenSSL to refuse to connect. This `requests` HTTP Adapter configures
OpenSSL to allow "unsafe legacy renegotiation", allowing EA Origin to
connect. This is only intended as a temporary workaround, and should be
removed as soon as accounts.ea.com is updated to support RFC 5746.

Using this adapter will reduce the security of the connection. However, the
impact should be relatively minimal this is only used to connect to EA
services. See CVE-2009-3555 for more details.

See #4235 for more information.
c                s    Wn         W n        W0n        \        P                  ! 4       pV;P
                  \        ,          un        \        P                  ! RRVRVRVRRRV/VB V n	        R# )	zAOverride the default PoolManager to allow insecure renegotiation.Z	num_poolsmaxsizeblockZstrictTssl_contextNrE   )
_pool_connections_pool_maxsize_pool_blocksslZcreate_default_contextZoptions(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATIONurllib3ZPoolManagerpoolmanager)r   ZconnectionsrX   rY   Zpool_kwargsrZ   s   &&&&, r   init_poolmanagerZ/LegacyRenegotiationHTTPAdapter.init_poolmanageru   s     "-$ 002GG".. 
!

 
 	

 $
 
r    )r]   r[   r\   ra   N)F)r*   r+   r,   r-   __doc__rb   r.   r/   r0   r2   r   rW   rW   d   s      
 
r    rW   c                   s0  a a ] tR t^t oRtRt]! R4      tRtRt	Rt
RtRtRtR	]R
]R]/tR	t]P(                  P+                  ]P.                  R4      t]P(                  P+                  ]P.                  R4      t]P(                  P+                  ]P.                  R4      tRtRtR.tR],          tRt]P@                  R,           t!V 3R lt"]#R 4       t$R t%R t&R t'R t(R+V3R lR llt)R t*R t+R t,R  t-R! t.R" t/R# t0R$ t1R% t2R& t3R' t4R( t5R) t6R*t7Vt8V ;t9# ),EAAppServicezService class for EA Appr4   zEA Appea-appi  i  ZwineTrH   rK   rM   zea_app/cache/zea_app/cookieszea_app/auth_tokenz'https://www.origin.com/views/login.htmlzhttps://www.ea.com/loginzhttps://www.ea.com/zhttps://accounts.ea.com/connect/auth?response_type=code&client_id=ORIGIN_SPA_ID&display=originXWeb/login&locale=en_US&release_type=prod&redirect_uri=%sz5https://service-aggregation-layer.juno.ea.com/graphqlz QtWebEngine/5.8.0c                s   < \         SV `  4        \        P                  ! 4       V n        V P                  P	                  R \        4       4       V P                  4       V n        R# )zhttps://N)Zsuperr   requestssessionZmountrW   load_access_tokenaccess_token)r   	__class__s   &r   r   ZEAAppService.__init__   sG    ''):'E'GH 224r    c                s`    R V P                   /pVP                  V P                  4       4       V# )z
User-Agent)login_user_agentupdateget_auth_headers)r   headersr$   r   api_headersZEAAppService.api_headers   s,    !6!67t,,./r    c                s,    \        V P                  4      # r!   )Zboolri   r8   r9   r   is_connectedZEAAppService.is_connected   s    D%%&&r    c                sR    V P                  4        \        P                  ! V 4       R # r!   )fetch_access_tokenr   Zfire)r   Zurlr   r   login_callbackZEAAppService.login_callback   s    !4 r    c           	     s<   V P                  4       pV'       g   \        R 4      h\        V P                  RRR7      ;_uu_ 4       pVP	                  \
        P                  ! V^R7      4       RRR4       V P                  4       V n        R#   + '       g   i     L'; i)zFailed to get access tokenZwutf-8Zencoding)ZindentN)	get_access_tokenRuntimeErroropen
token_pathZwriterR   rS   rh   ri   )r   
token_data
token_file   &  r   rq   ZEAAppService.fetch_access_token   sl    **,
;<<$//399ZTZZ
1=> : 224 :9s   (BB	c                s0   \         P                  P                  V P                  4      '       g   R # \	        V P                  RR7      ;_uu_ 4       p\
        P                  ! V4      pVP                  RR 4      uuRRR4       #   + '       g   i     R# ; i)Z rs   rt   ri   N)r   r   r"   rx   rw   rR   loadrB   )r   rz   ry   r{   r   rh   ZEAAppService.load_access_token   sZ    ww~~doo..$//G44
:.J>>."5 5444s   (BB	c                s    < V ^8  d   QhRS[ /# )r;   params)dictr>   r?   r   r@   ZEAAppService.__annotate__   s      t r    c           	     s    V P                   P                  V P                  V P                  R TRT;'       g    / /R7      P	                  4       pRV9   d   \        RVR,          4      hV# )query	variables)rn   rR   Zerrorsz.Errors occurred while running an EA api query.)rg   Zpostapi_urlro   rR   rv   )r   r   r}   results   &&& r   	fetch_apiZEAAppService.fetch_api   sm    ""LL$"2"2'5+W]WcWcac9d # 

$& 	 vOQWX`Qabbr    c                s    V P                   P                  RRRRRRRRR	/V P                  4       R
7      pVP                  4        VP	                  4       pV# )zRequest an access token from EAz$https://accounts.ea.com/connect/authZ	client_idZORIGIN_JS_SDKZresponse_typeZtokenZredirect_uriznucleus:restZpromptZnone)r}   cookies)rg   rB   load_cookiesZraise_for_statusrR   )r   responsery   r{   r   ru   ZEAAppService.get_access_token   sd    <<##2_&	 %%' $ 	
 	!!#]]_
r    c                s    V P                   P                  R V P                  4       V P                  4       R7      pVP	                  4       # )z-https://gateway.ea.com/proxy/identity/pids/me)r   rn   )rg   rB   r   rm   rR   )r   r   r$   r   _request_identityZEAAppService._request_identity   sD    <<##;%%'))+ $ 

 }}r    c                s    V P                  4       pVP                  R4      R8X  d8   \        P                  ! R4       V P	                  4        V P                  4       pM8VP                  R4      '       d"   \        VR,          : RVR,          : R24      hRV9   d   \        VR,          4      hV P                  R4      R,          R	,          R
,          pVR,          pVR,          pVR,          p\        V4      \        V4      \        V4      3# )zRequest the user infoerrorZinvalid_access_tokenzRefreshing EA access tokenz (Error code: Zerror_numberZ)z%query{me{player{pd psd displayName}}}datameplayerZpdZpsdZdisplayName)r   rB   r   r&   rq   rv   r   r=   )r   Zidentity_datar   user_idZ
persona_idZ	user_names   &     r   get_identityZEAAppService.get_identity   s    ..0W%)??NN78##% 224Mw''g8N8NP]^lPmPmnoom#}W566 GHPQUVW_`,E]
=)	7|S_c)n<<r    c                s   V P                  4       w  rpV P                  V4      p\        P                  ! R \	        V4      4       . pV F9  p\
        P                  V4      pVP                  4        VP                  V4       K;  	  V# )z"Retrieved %s games from EA library)	r   get_libraryr   ZinfolenrN   rV   Zsaver'   )r   r   Z_persona_idZ
_user_namegamesZea_gamesrT   rU   s   &       r   r|   ZEAAppService.load  ss    +/+<+<+>(j  )8#e*ED,,T2GLLNOOG$  r    c           	     s0   ^dp. p\        \        R V P                  V4      4      4      p\        ^ \	        V4      V4       Uu. uF  qTWUV,            NK  	  up F0  pY0P                  V Uu. uF  qwR,          NK  	  up4      ,          pK2  	  V# u upi u upi )zLoad EA libraryc                 s\    V R ,          RJ;'       d    V R ,          R,          R,          R8H  # )productNrA   ZgameTypeZ	BASE_GAMErE   )er9   r   Z<lambda>Z*EAAppService.get_library.<locals>.<lambda>  s-    !I,d2jjq|J7OPZ7[_j7jjr    originOfferId)ZlistZfilterget_entitlementsZranger   	get_games)r   r   Z
chunk_sizer   ZentitlementsZiZchunkr   s   &&      r   r   ZEAAppService.get_library  s    
j%%g.
 AFa\IZ\f@gh@g11:~6@ghE^^$GA%7%7$GHHE i i$Gs   B*Bc                s   V P                  RRV/R7      p. pVR,          P                  R4      pVR,          P                  R4      ;'       g    / P                  R. 4      pV Uu/ uFF  p\        V\        4      '       g   K  VP                  R4      '       g   K4  VP                  R4      VbKH  	  ppV Uu/ uFF  p\        V\        4      '       g   K  VP                  R	4      '       g   K4  VP                  R	4      VbKH  	  ppV F  p	\        V	\        4      '       g   K  V	R
,          p
V	R,          pV
'       g   K7  VP                  V
4      ;'       g?    T;'       d    VP                  V4      ;'       g    VP                  V
4      ;'       g    / pV'       g   K  RV/pVP	                  V4       VP                  V4       K  	  V# u upi u upi )zLoad game details from EAa  query getOffers($offerIds: [String!]!) {
                legacyOffers(offerIds: $offerIds, locale: "DEFAULT") {
                    offerId: id
                    contentId
                }
                gameProducts(offerIds: $offerIds, locale: "DEFAULT") {
                    items {
                        id
                        originOfferId
                        gameSlug
                        baseItem {
                            keyArt {
                                largestImage { path }
                            }
                            packArt {
                                largestImage { path }
                            }
                            primaryLogo {
                                largestImage { path }
                            }
                            title
                        }
                    }
                }
            }
            ZofferIdsr}   r   ZlegacyOffersZgameProductsitemsr   idZofferIdrO   )r   rB   Z
isinstancer~   rl   r'   )r   Z	offer_idsr   r   Zlegacy_offersZgame_productsZpZby_offerZby_product_idZlegacy_offeroffer_id
content_idr   rT   s   &&            r   r   ZEAAppService.get_games  s   4 	*7   
< v**>:++N;AArFFwPRS7Dw}!
STVZH[-`a`e`efu`v-AEE/*A-}w1>fA*QPTBUZ[Z_Z_`dZetaf)LlD11#I.H%k2JX&  @@=#4#4Z#@  $$X.  	  ,DKK LL' *( / xfs$   &GGG8GG.Gc                s    . pR^d/p V P                  RVR7      pVR,          R,          R,          pVR,          VR&   W%R,          ,          pVR,          e   KS   V# )	zRequest the user's entitlementsZlimita  query getEntitlements($limit: Int, $next: String) {
                    me {
                        ownedGameProducts(
                            locale: "DEFAULT"
                            entitlementEnabled: true
                            storefronts: [EA]
                            type: [DIGITAL_FULL_GAME, PACKAGED_FULL_GAME]
                            platforms: [PC]
                            paging: {
                                limit: $limit,
                                next: $next
                            }
                        ) {
                            next,
                            items {
                                originOfferId
                                product {
                                    baseItem {
                                        gameType
                                    }
                                }
                            }
                        }
                    }
                }r   r   r   ZownedGameProductsZnextr   )r   )r   r   r   r   r   Zproductss   &&    r   r   ZEAAppService.get_entitlementsV  su    cN	^^2 !5 $ F: f~d+,?@H ( 0Ifg&&E'r    c                s    V P                   '       g   \        R4      hRRV P                   ,          RV P                   RV P                   /# )z3Return headers needed to authenticate HTTP requestszUser not authenticated to EAZAuthorizationz	Bearer %sZ	AuthTokenzX-AuthToken)ri   rv   r8   r9   r   rm   ZEAAppService.get_auth_headers  sJ       =>>[4+<+<<**4,,
 	
r    c                sF   \        R R4      pV'       g   \        P                  ! R4       VR,          P                  R4      ^ ,          p\        P
                  P                  \        P
                  P                  VR4      4      '       g   \        P                  ! RV4       R# \        V4      p. pVP                  4        F/  pV P                  W4      pV'       g   K  VP                  V4       K1  	  \        V4       \        P                  ! R\        V4      4       R# )re   rQ   zEA App is not installed	directoryr   zInvalid install of EA App at %sNzInstalled %s EA games)r
   r   r   Zsplitr   r   r"   r   r   r)   install_from_ea_appr'   r   debugr   )r   ea_app_gameZea_app_prefixZea_app_launcherZinstalled_slugscontent_idsrQ   r(   r   add_installed_gamesZ EAAppService.add_installed_games  s    '&9LL23#K066yA!Dww~~bggll=)DEELL:MJ$]3*JJLK++KEDt&&t, M 	?#,c/.BCr    c                sV   V^ ,          p\         P                  ! RV4       \        P                  ! RV4      pV'       g   \         P                  ! RV4       R# \        VR,          4      R,           V P                  ,           p\        VR4      pV'       d   R# \        VR,          R	7      P                  p\        R
P                  V4      4      VR,          R&   \        WW4      pV P                  V4      p	\        VR,          VR,          V	VR,          ^VVV P                  VR7	       V	# )i    zInstalling EA game %sr4   z8Aborting install, %s is not present in the game library.Nr7   -installer_slug
configpath)Zgame_config_idZ,rT   argsrunnerr   )	r7   r   rQ   r   	installedr   r   r6   Z
service_id)r   r   r   Zget_gamer   r   r   r
   r   Z
game_levelget_launch_argumentsr   r   get_installed_slugr	   )
r   rU   r   r   Zservice_gameZlutris_game_idZexisting_gamegame_configr   rQ   s
   &&&       r   r   Z EAAppService.install_from_ea_app  s    q>,h7,55hILLSU]^ f!56<twwF).:JK"',2GHSS&:388K;P&QFF#&~C
&&w/f%8$k*)!GG
	
 r    c                s   \        VR ,          4      pVP                  P                  R,          p\        P                  P                  V4      '       g<   \        P                  P                  VP                  P                  R,          V4      pRVR,          RV P                  R\        VR,          4      R,           V P                  ,           RV P                  V4      RV P                  V4      R	VR	,          R
RV P                  RR\        VR	,          4      /RRRRRVR\        VR	,          4      RVP                  P                  R,          RRVR,          ,          //.//# )r   ZexeZprefixr7   ZversionrQ   r   	game_slugr   rP   ZscriptZrequiresrT   r   Z	installerZtaskZwineexecZ
executableZdescriptionz2EA App will now open and prompt you to install %s.)r   Zconfigr   r   r   Zisabsr   r7   r   r   r   get_installed_runner_nameclient_installerr   )r   db_gameZ
ea_db_gamerU   Zea_exes   &&&  r   generate_installerZEAAppService.generate_installer  s?   z$'(++E2ww}}V$$WW\\'.."<"<X"FOFGFOtyyGGFO,s2TWW<009d44W=WW%D1101AB "J(&"$89I$J$gnn&@&@&J),`cjkqcr,r!

 	
r    c                s    V P                   # r!   )r   )r   r   r   r   r   Z&EAAppService.get_installed_runner_name  s    {{r    c                sX   \        V P                  R 4      p\        P                  P	                  4       pV'       d   VR,          '       g5   \
        P                  ! R4       VP                  V P                  R7       R# VP                  V P                  W4      .WR,          R7       R# )rQ   r   zInstalling the EA App client)r   rP   )r6   rP   N)
r
   r   r   ZApplicationZget_defaultr   r&   Zshow_lutris_installer_windowZshow_installer_windowr   )r   r   r   Zapplications   &&  r   installZEAAppService.install  s    '(=(=vFoo113+k":":NN9:44t?T?T4U--((>?]dUe . r    )ri   rg   r!   ):r*   r+   r,   r-   rc   r   _r7   Ziconr   Zlogin_window_widthZlogin_window_heightr   ZonlinerG   rJ   rL   ZmediasZdefault_formatr   r   r   r   r5   Z
cache_pathZcookies_pathrx   Zorigin_redirect_uriZ	login_urlZredirect_urisZorigin_login_urlr   ZDEFAULT_USER_AGENTrk   r   rF   ro   rp   rr   rq   rh   r   ru   r   r   r|   r   r   r   rm   r   r   r   r   r   r.   r/   Z__classcell__)rj   r1   s   @@r   rd   rd      sd    "	BX;DDFF+<'F
 Nh00/BJ77<< 2 24DELh002EFJC*I*+M	 	 FG225II5  
'!56  =&	:x'R
D"8
>	 	r    rd   c                s    RV RV  R2# )z|Return launch argument for EA games.
download used to be a valid action but it doesn't seem like it's implemented in EA App.zorigin2://game/z
?offerIds=z&autoDownload=1rE   )r   Zactionr   r   r   r     s     VHJzl/JJr    i   )Zlaunch)5rc   rR   r   r^   r    r   Ztypingr   r   r   Z	xml.etreer   rf   r`   Zgi.repositoryr   Zlutrisr   Zlutris.configr   r   Zlutris.database.gamesr	   r
   Zlutris.database.servicesr   Zlutris.gamer   Zlutris.services.baser   r   Zlutris.services.lutrisr   Zlutris.services.service_gamer   Zlutris.services.service_mediar   Zlutris.util.logr   Zlutris.util.stringsr   r_   r   r3   rG   rJ   rL   rN   ZadaptersZHTTPAdapterrW   rd   r   rE   r    r   <module>r      s      	 
   & & !     9 = :  = - 4 6 " '+2 (" ":F F* 
: 
z 

 
"
X%6%6%B%B "
JX= Xv
Kr    