2016-02-13 17:06:36 -06:00
# -*- coding: utf-8 -*-
2019-01-01 19:42:53 -06:00
from __future__ import unicode_literals
2018-12-23 10:06:06 -06:00
import time
2016-02-13 17:06:36 -06:00
import wx
import widgetUtils
2018-12-23 10:06:06 -06:00
code = None
remember = True
2016-02-22 13:15:10 -06:00
def new_account_dialog ( ) :
2019-01-01 19:42:53 -06:00
return wx . MessageDialog ( None , _ ( " In order to continue, you need to configure your VK account before. Would you like to autorhise a new account now? " ) , _ ( " Authorisation " ) , wx . YES_NO ) . ShowModal ( )
2016-02-13 17:06:36 -06:00
2018-12-19 17:34:51 -06:00
def two_factor_auth ( ) :
2018-12-23 10:06:06 -06:00
global code , remember
wx . CallAfter ( get_code )
while code == None :
time . sleep ( 0.5 )
return ( code , remember )
def get_code ( ) :
global code , remember
2019-01-01 19:42:53 -06:00
dlg = wx . TextEntryDialog ( None , _ ( " Please provide the authentication code you have received from VK. " ) , _ ( " Two factor authentication code " ) )
2018-12-19 17:34:51 -06:00
response = dlg . ShowModal ( )
if response == widgetUtils . OK :
2018-12-23 10:06:06 -06:00
code = dlg . GetValue ( )
2018-12-19 17:34:51 -06:00
dlg . Destroy ( )
dlg . Destroy ( )
2016-02-13 17:06:36 -06:00
class newSessionDialog ( widgetUtils . BaseDialog ) :
def __init__ ( self ) :
2019-01-01 19:42:53 -06:00
super ( newSessionDialog , self ) . __init__ ( parent = None , id = wx . NewId ( ) , title = _ ( " Authorise VK " ) )
2016-02-13 17:06:36 -06:00
panel = wx . Panel ( self )
2019-01-01 19:42:53 -06:00
lbl1 = wx . StaticText ( panel , - 1 , _ ( " &Email or phone number " ) )
2016-02-13 17:06:36 -06:00
self . email = wx . TextCtrl ( panel , - 1 )
2019-01-01 19:42:53 -06:00
lbl2 = wx . StaticText ( panel , - 1 , _ ( " &Password " ) )
2016-02-13 17:06:36 -06:00
self . passw = wx . TextCtrl ( panel , - 1 , style = wx . TE_PASSWORD )
sizer = wx . BoxSizer ( )
b1 = wx . BoxSizer ( wx . HORIZONTAL )
b1 . Add ( lbl1 , 0 , wx . ALL , 5 )
b1 . Add ( self . email , 0 , wx . ALL , 5 )
b2 = wx . BoxSizer ( wx . HORIZONTAL )
b2 . Add ( lbl2 , 0 , wx . ALL , 5 )
b2 . Add ( self . passw , 0 , wx . ALL , 5 )
sizer . Add ( b1 , 0 , wx . ALL , 5 )
sizer . Add ( b2 , 0 , wx . ALL , 5 )
ok = wx . Button ( panel , wx . ID_OK )
2016-06-29 13:16:35 -05:00
ok . SetDefault ( )
2016-02-13 17:06:36 -06:00
cancel = wx . Button ( panel , wx . ID_CANCEL )
btnb = wx . BoxSizer ( wx . HORIZONTAL )
btnb . Add ( ok , 0 , wx . ALL , 5 )
btnb . Add ( cancel , 0 , wx . ALL , 5 )
sizer . Add ( btnb , 0 , wx . ALL , 5 )
panel . SetSizer ( sizer )
def get_email ( self ) :
return self . email . GetValue ( )
def get_password ( self ) :
return self . passw . GetValue ( )