NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

web.py (1540B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\evelink\client\handlers\web.py
      2 import blue
      3 from carbonui import uiconst
      4 from carbonui.uicore import uicore
      5 from evelink.client.color import external_link_color_info
      6 from localization import GetByLabel
      7 from menu import MenuLabel
      8 from player_messaging import PromptIcon
      9 from player_messaging.client.ui_message import prompt_player, prompt_player_fsd_dialog
     10 from url_utils.client.canonical import canonical_safe_url
     11 SCHEMES = ('http', 'https')
     12 
     13 def register_web_handlers(registry):
     14     for scheme in SCHEMES:
     15         registry.register(scheme, handle_web_link, menu=get_menu, color_info=external_link_color_info, hint=lambda url: url)
     16 
     17 
     18 def handle_web_link(url):
     19     safe_url = canonical_safe_url(url)
     20     if safe_url is None:
     21         prompt_player(url, GetByLabel('UI/Shared/InvalidOrSpoofedLink'), options=uiconst.OK, icon=PromptIcon.ERROR)
     22         return
     23     if uicore.registry.IsModalWindowOpen():
     24         response = uiconst.ID_OK
     25     else:
     26         response = prompt_player_fsd_dialog('ExternalLinkWarning', {'url': safe_url}, uiconst.OKCANCEL, suppress=uiconst.ID_OK)
     27     if response == uiconst.ID_OK:
     28         try:
     29             blue.os.ShellExecute(safe_url)
     30         except WindowsError as error:
     31             if error.winerror not in ACCEPTABLE_WINDOWS_SYSTEM_ERRORS:
     32                 raise
     33 
     34 
     35 ACCEPTABLE_WINDOWS_SYSTEM_ERRORS = (0, 2, 5, 1223)
     36 
     37 def get_menu(url):
     38     return [(MenuLabel('/Carbon/UI/Commands/CopyURL'), blue.pyos.SetClipboardData, (url,))]