Develop dialog and keep SSO server running as long as dialog remains active (#1859)
This commit is contained in:
@@ -62,13 +62,11 @@ from gui.preferenceDialog import PreferenceDialog
|
||||
from gui.resistsEditor import ResistsEditorDlg
|
||||
from gui.setEditor import ImplantSetEditorDlg
|
||||
from gui.shipBrowser import ShipBrowser
|
||||
from gui.ssoLogin import SsoLogin
|
||||
from gui.statsPane import StatsPane
|
||||
from gui.updateDialog import UpdateDialog
|
||||
from gui.utils.clipboard import fromClipboard, toClipboard
|
||||
from service.character import Character
|
||||
from service.esi import Esi, LoginMethod
|
||||
from service.esiAccess import SsoMode
|
||||
from service.esi import Esi
|
||||
from service.fit import Fit
|
||||
from service.port import EfsPort, IPortUser, Port
|
||||
from service.settings import HTMLExportSettings, SettingsProvider
|
||||
@@ -230,20 +228,11 @@ class MainFrame(wx.Frame):
|
||||
self.sUpdate.CheckUpdate(self.ShowUpdateBox)
|
||||
|
||||
self.Bind(GE.EVT_SSO_LOGIN, self.onSSOLogin)
|
||||
self.Bind(GE.EVT_SSO_LOGGING_IN, self.ShowSsoLogin)
|
||||
|
||||
@property
|
||||
def command(self) -> wx.CommandProcessor:
|
||||
return Fit.getCommandProcessor(self.getActiveFit())
|
||||
|
||||
def ShowSsoLogin(self, event):
|
||||
if getattr(event, "login_mode", LoginMethod.SERVER) == LoginMethod.MANUAL and getattr(event, "sso_mode", SsoMode.AUTO) == SsoMode.AUTO:
|
||||
dlg = SsoLogin(self)
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
sEsi = Esi.getInstance()
|
||||
# todo: verify that this is a correct SSO Info block
|
||||
sEsi.handleLogin({'SSOInfo': [dlg.ssoInfoCtrl.Value.strip()]})
|
||||
|
||||
def ShowUpdateBox(self, release, version):
|
||||
dlg = UpdateDialog(self, release, version)
|
||||
dlg.ShowModal()
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import wx
|
||||
import gui.mainFrame
|
||||
import webbrowser
|
||||
import gui.globalEvents as GE
|
||||
|
||||
|
||||
class SsoLogin(wx.Dialog):
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="SSO Login", size=wx.Size(400, 240))
|
||||
def __init__(self):
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
wx.Dialog.__init__(self, mainFrame, id=wx.ID_ANY, title="SSO Login", size=wx.Size(400, 240))
|
||||
|
||||
bSizer1 = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
@@ -24,3 +29,55 @@ class SsoLogin(wx.Dialog):
|
||||
|
||||
self.SetSizer(bSizer1)
|
||||
self.Center()
|
||||
|
||||
mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)
|
||||
|
||||
from service.esi import Esi
|
||||
|
||||
self.sEsi = Esi.getInstance()
|
||||
uri = self.sEsi.getLoginURI(None)
|
||||
webbrowser.open(uri)
|
||||
|
||||
def OnLogin(self, event):
|
||||
self.Close()
|
||||
event.Skip()
|
||||
|
||||
|
||||
class SsoLoginServer(wx.Dialog):
|
||||
def __init__(self, port):
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
wx.Dialog.__init__(self, mainFrame, id=wx.ID_ANY, title="SSO Login", size=(-1, -1))
|
||||
|
||||
from service.esi import Esi
|
||||
|
||||
self.sEsi = Esi.getInstance()
|
||||
serverAddr = self.sEsi.startServer(port)
|
||||
|
||||
uri = self.sEsi.getLoginURI(serverAddr)
|
||||
|
||||
bSizer1 = wx.BoxSizer(wx.VERTICAL)
|
||||
mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnClose)
|
||||
|
||||
text = wx.StaticText(self, wx.ID_ANY, "Waiting for character login through EVE Single Sign-On.")
|
||||
bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10)
|
||||
|
||||
bSizer3 = wx.BoxSizer(wx.VERTICAL)
|
||||
bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 10)
|
||||
|
||||
bSizer3.Add(self.CreateStdDialogButtonSizer(wx.CANCEL), 0, wx.EXPAND)
|
||||
bSizer1.Add(bSizer3, 0, wx.BOTTOM | wx.RIGHT | wx.LEFT | wx.EXPAND, 10)
|
||||
|
||||
self.SetSizer(bSizer1)
|
||||
self.Fit()
|
||||
self.Center()
|
||||
|
||||
webbrowser.open(uri)
|
||||
|
||||
def OnLogin(self, event):
|
||||
self.Close()
|
||||
event.Skip()
|
||||
|
||||
def OnClose(self, event):
|
||||
self.sEsi.stopServer()
|
||||
event.Skip()
|
||||
|
||||
Reference in New Issue
Block a user