mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-07 19:03:23 +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):
|
def init(self):
|
||||||
self = objc.super(EventHandler, self).init()
|
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
|
return self
|
||||||
|
|
||||||
def handleEvent_withReplyEvent_(self, event, replyEvent):
|
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)
|
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:
|
elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver:
|
||||||
|
|
||||||
class WNDCLASS(Structure):
|
class WNDCLASS(Structure):
|
||||||
_fields_ = [('style', UINT),
|
_fields_ = [
|
||||||
|
('style', UINT),
|
||||||
('lpfnWndProc', WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM)),
|
('lpfnWndProc', WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM)),
|
||||||
('cbClsExtra', INT),
|
('cbClsExtra', INT),
|
||||||
('cbWndExtra', 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.argtypes = [HGLOBAL]
|
||||||
GlobalUnlock.restype = BOOL
|
GlobalUnlock.restype = BOOL
|
||||||
|
|
||||||
|
|
||||||
@WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM)
|
@WINFUNCTYPE(c_long, HWND, UINT, WPARAM, LPARAM)
|
||||||
def WndProc(hwnd, message, wParam, lParam):
|
def WndProc(hwnd, message, wParam, lParam):
|
||||||
service = create_unicode_buffer(256)
|
service = create_unicode_buffer(256)
|
||||||
topic = create_unicode_buffer(256)
|
topic = create_unicode_buffer(256)
|
||||||
if message == WM_DDE_INITIATE:
|
if message == WM_DDE_INITIATE:
|
||||||
if ((lParam & 0xffff == 0 or (GlobalGetAtomName(lParam & 0xffff, service, 256) and service.value == appname)) and
|
if (
|
||||||
(lParam >> 16 == 0 or (GlobalGetAtomName(lParam >> 16, topic, 256) and topic.value.lower() == 'system'))):
|
(lParam & 0xffff == 0 or (GlobalGetAtomName(lParam & 0xffff, service, 256) and service.value == appname)) and
|
||||||
SendMessage(wParam, WM_DDE_ACK, hwnd, PackDDElParam(WM_DDE_ACK, GlobalAddAtom(appname), GlobalAddAtom('System')))
|
(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 0
|
||||||
return DefWindowProc(hwnd, message, wParam, lParam)
|
return DefWindowProc(hwnd, message, wParam, lParam)
|
||||||
|
|
||||||
|
|
||||||
class ProtocolHandler(GenericProtocolHandler):
|
class ProtocolHandler(GenericProtocolHandler):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -179,7 +187,8 @@ elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine a
|
|||||||
wndclass.lpszClassName = 'DDEServer'
|
wndclass.lpszClassName = 'DDEServer'
|
||||||
|
|
||||||
if RegisterClass(byref(wndclass)):
|
if RegisterClass(byref(wndclass)):
|
||||||
hwnd = CreateWindowEx(0,
|
hwnd = CreateWindowEx(
|
||||||
|
0,
|
||||||
wndclass.lpszClassName,
|
wndclass.lpszClassName,
|
||||||
"DDE Server",
|
"DDE Server",
|
||||||
0,
|
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
|
self.master.winfo_id(), # Don't use HWND_MESSAGE since the window won't get DDE broadcasts
|
||||||
None,
|
None,
|
||||||
wndclass.hInstance,
|
wndclass.hInstance,
|
||||||
None)
|
None
|
||||||
|
)
|
||||||
msg = MSG()
|
msg = MSG()
|
||||||
while GetMessage(byref(msg), None, 0, 0) != 0:
|
while GetMessage(byref(msg), None, 0, 0) != 0:
|
||||||
logger.trace(f'DDE message of type: {msg.message}')
|
logger.trace(f'DDE message of type: {msg.message}')
|
||||||
@ -275,7 +285,8 @@ else: # Linux / Run from source
|
|||||||
if self.parse():
|
if self.parse():
|
||||||
self.send_header('Content-Type', 'text/html')
|
self.send_header('Content-Type', 'text/html')
|
||||||
self.end_headers()
|
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'))
|
self.wfile.write('<body><p>{}</p></body>'.format('Authentication successful').encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user