mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 01:52:20 +03:00
Autoformatted code
This commit is contained in:
parent
64f090487e
commit
47d5dce6fe
33
protocol.py
33
protocol.py
@ -68,18 +68,25 @@ if sys.platform == 'darwin' and getattr(sys, 'frozen', False):
|
||||
|
||||
def init(self):
|
||||
self = objc.super(EventHandler, self).init()
|
||||
NSAppleEventManager.sharedAppleEventManager().setEventHandler_andSelector_forEventClass_andEventID_(self, 'handleEvent:withReplyEvent:', kInternetEventClass, kAEGetURL)
|
||||
NSAppleEventManager.sharedAppleEventManager().setEventHandler_andSelector_forEventClass_andEventID_(
|
||||
self,
|
||||
'handleEvent:withReplyEvent:',
|
||||
kInternetEventClass,
|
||||
kAEGetURL
|
||||
)
|
||||
return self
|
||||
|
||||
def handleEvent_withReplyEvent_(self, event, replyEvent):
|
||||
protocolhandler.lasturl = urllib.parse.unquote(event.paramDescriptorForKeyword_(keyDirectObject).stringValue()).strip()
|
||||
protocolhandler.lasturl = urllib.parse.unquote(
|
||||
event.paramDescriptorForKeyword_(keyDirectObject).stringValue()).strip()
|
||||
protocolhandler.master.after(ProtocolHandler.POLL, protocolhandler.poll)
|
||||
|
||||
|
||||
elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver:
|
||||
|
||||
class WNDCLASS(Structure):
|
||||
_fields_ = [('style', UINT),
|
||||
_fields_ = [
|
||||
('style', UINT),
|
||||
('lpfnWndProc', WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM)),
|
||||
('cbClsExtra', INT),
|
||||
('cbWndExtra', INT),
|
||||
@ -133,19 +140,20 @@ elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine a
|
||||
GlobalUnlock.argtypes = [HGLOBAL]
|
||||
GlobalUnlock.restype = BOOL
|
||||
|
||||
|
||||
@WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM)
|
||||
def WndProc(hwnd, message, wParam, lParam):
|
||||
service = create_unicode_buffer(256)
|
||||
topic = create_unicode_buffer(256)
|
||||
if message == WM_DDE_INITIATE:
|
||||
if ((lParam & 0xffff == 0 or (GlobalGetAtomName(lParam & 0xffff, service, 256) and service.value == appname)) and
|
||||
(lParam >> 16 == 0 or (GlobalGetAtomName(lParam >> 16, topic, 256) and topic.value.lower() == 'system'))):
|
||||
SendMessage(wParam, WM_DDE_ACK, hwnd, PackDDElParam(WM_DDE_ACK, GlobalAddAtom(appname), GlobalAddAtom('System')))
|
||||
if (
|
||||
(lParam & 0xffff == 0 or (GlobalGetAtomName(lParam & 0xffff, service, 256) and service.value == appname)) and
|
||||
(lParam >> 16 == 0 or (GlobalGetAtomName(lParam >> 16, topic, 256) and topic.value.lower() == 'system'))
|
||||
):
|
||||
SendMessage(wParam, WM_DDE_ACK, hwnd, PackDDElParam(
|
||||
WM_DDE_ACK, GlobalAddAtom(appname), GlobalAddAtom('System')))
|
||||
return 0
|
||||
return DefWindowProc(hwnd, message, wParam, lParam)
|
||||
|
||||
|
||||
class ProtocolHandler(GenericProtocolHandler):
|
||||
|
||||
def __init__(self):
|
||||
@ -179,7 +187,8 @@ elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine a
|
||||
wndclass.lpszClassName = 'DDEServer'
|
||||
|
||||
if RegisterClass(byref(wndclass)):
|
||||
hwnd = CreateWindowEx(0,
|
||||
hwnd = CreateWindowEx(
|
||||
0,
|
||||
wndclass.lpszClassName,
|
||||
"DDE Server",
|
||||
0,
|
||||
@ -187,7 +196,8 @@ elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine a
|
||||
self.master.winfo_id(), # Don't use HWND_MESSAGE since the window won't get DDE broadcasts
|
||||
None,
|
||||
wndclass.hInstance,
|
||||
None)
|
||||
None
|
||||
)
|
||||
msg = MSG()
|
||||
while GetMessage(byref(msg), None, 0, 0) != 0:
|
||||
logger.trace(f'DDE message of type: {msg.message}')
|
||||
@ -275,7 +285,8 @@ else: # Linux / Run from source
|
||||
if self.parse():
|
||||
self.send_header('Content-Type', 'text/html')
|
||||
self.end_headers()
|
||||
self.wfile.write('<html><head><title>{}</title></head>'.format('Authentication successful').encode('utf-8'))
|
||||
self.wfile.write(
|
||||
'<html><head><title>{}</title></head>'.format('Authentication successful').encode('utf-8'))
|
||||
self.wfile.write('<body><p>{}</p></body>'.format('Authentication successful').encode('utf-8'))
|
||||
else:
|
||||
self.end_headers()
|
||||
|
Loading…
x
Reference in New Issue
Block a user