app-gui
quadrismegistus 4 years ago
parent 78fb19a4a5
commit f28dad6c8d

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 286 KiB

@ -126,8 +126,9 @@ class MessagePopupCard(MDDialog):
super().__init__(*x,**y)
self.ok_to_continue=False
def on_dismiss(self):
return True
#def on_dismiss(self):
# return True
def on_touch_down(self,touch):
self.ok_to_continue=True
logger.info('oof!')
@ -398,7 +399,53 @@ class MainApp(MDApp, Logger):
self.dialog.open()
#stop
async def stat(self,msg,komrade_name='Telephone',pause=False,**y):
async def get_input(self,msg,komrade_name='Telephone',get_pass=False):
from komrade.app.screens.feed.feed import PostCard,PostCardPopup
if hasattr(self,'msg_dialog') and self.msg_dialog:# and hasattr(self.msg_dialog,'card') and self.msg_dialog.card:
self.msg_dialog0=self.msg_dialog
self.msg_dialog = MessagePopupCard()
self.msg_dialog.card = postcard = PostCardPopup({
'author':komrade_name,
'author_prefix':'@',
'to_name':'me',
'content':msg,
'timestamp':time.time(),
'author_label_font_size':'18sp',
**y
},
msg_dialog=self.msg_dialog)
postcard.font_size='16sp'
postcard.size_hint=(None,None)
postcard.size=('600sp','600sp')
postcard.ok_to_continue=False
if get_pass:
from komrade.app.screens.login.login import PasswordField
field = PasswordField()
field.line_color_focus=rgb(*COLOR_TEXT)
field.line_color_normal=rgb(*COLOR_TEXT,a=0.25)
field.font_name='assets/font.otf'
postcard.add_widget(field,1)
self.msg_dialog.add_widget(postcard)
self.msg_dialog.open()
if hasattr(self,'msg_dialog0'):
self.msg_dialog0.remove_widget(self.msg_dialog0.card)
self.root.remove_widget(self.msg_dialog0)
await asyncio.sleep(0.1)
while not self.msg_dialog.ok_to_continue:
await asyncio.sleep(0.1)
# logger.info(str(postcard), postcard.ok_to_continue,'??')
# self.msg_dialog.dismiss()
# self.msg_dialog.remove_widget(postcard)
# self.msg_dialog.card = postcard = self.msg_dialog = None
await asyncio.sleep(0.1)
return {'success':True, 'status':'Delivered popup message'}
async def stat(self,msg,komrade_name='Telephone',pause=False,get_pass=False,**y):
from komrade.app.screens.feed.feed import PostCard,PostCardPopup
if hasattr(self,'msg_dialog') and self.msg_dialog:# and hasattr(self.msg_dialog,'card') and self.msg_dialog.card:
self.msg_dialog0=self.msg_dialog
@ -412,13 +459,15 @@ class MainApp(MDApp, Logger):
'to_name':'me',
'content':msg,
'timestamp':time.time(),
'author_label_font_size':'18sp'
'author_label_font_size':'18sp',
**y
},
msg_dialog=self.msg_dialog)
postcard.font_size='16sp'
postcard.size_hint=(None,None)
postcard.size=('600sp','600sp')
postcard.ok_to_continue=False
self.msg_dialog.add_widget(postcard)
self.msg_dialog.open()

@ -116,14 +116,17 @@ class PostCard(MDCard):
if not self.recipient:
self.recipient=self.app.channel
self.img_id = data.get('file_id','')
self.img_ext = data.get('file_ext','')
self.img_src=self.img_id[:3]+'/'+self.img_id[3:]+'.'+self.img_ext if self.img_id else ''
self.cache_img_src = os.path.join('cache',self.img_src) if self.img_src else ''
self.img_loaded = os.path.exists(self.cache_img_src)
# self.img_id = data.get('file_id','')
# self.img_ext = data.get('file_ext','')
# self.img_src=self.img_id[:3]+'/'+self.img_id[3:]+'.'+self.img_ext if self.img_id else ''
# self.cache_img_src = os.path.join('cache',self.img_src) if self.img_src else ''
self.cache_img_src = self.img_src = data.get('img_src','')
self.img_loaded = self.img_src and os.path.exists(self.img_src)
self.content = data.get('content','')
self.timestamp = data.get('timestamp',None)
self.bind(minimum_height=self.setter('height'))
# self.bind(minimum_height=self.setter('height'))
author_prefix=data.get('author_prefix','@')
author_label_font_size=data.get('author_label_font_size','24sp')
recip_label_font_size=data.get('author_label_font_size','14sp')
@ -151,10 +154,10 @@ class PostCard(MDCard):
self.author_label.text+=f'\n[size={recip_label_font_size}]to '+recip+'[/size]'
self.author_label.markup=True
self.author_label.font_size = author_label_font_size
img_src = os.path.join(PATH_GUI_ASSETS, 'avatars', f'{self.author}.png')
if not os.path.exists(img_src):
img_src=PATH_DEFAULT_AVATAR
self.author_avatar = author_avatar = PostAuthorAvatar(source=img_src) #self.img_src)
avatar_img_src = os.path.join(PATH_GUI_ASSETS, 'avatars', f'{self.author}.png')
if not os.path.exists(avatar_img_src):
avatar_img_src=PATH_DEFAULT_AVATAR
self.author_avatar = author_avatar = PostAuthorAvatar(source=avatar_img_src) #self.img_src)
self.author_section_layout.add_widget(author_avatar)
self.author_section_layout.add_widget(author_label)
# self.author_section_layout.add_widget(MDSeparator(height='1sp',size_hint=(None,None)))

@ -162,6 +162,13 @@ class LoginScreen(BaseScreen):
return self.password_field.text if not passphrase else passphrase
async def boot(self,un,pw=None):
# await self.stat('hello',img_src='/home/ryan/komrade/data/contacts/marxxx.png',komrade_name='Keymaker')
await self.stat('hello?',get_pass=True)
return
# return
name=un
from komrade.backend import Komrade
kommie = Komrade(un,getpass_func=lambda why: pw)
@ -190,7 +197,7 @@ class LoginScreen(BaseScreen):
await self.app.stat('This is a contact of yours')
self.login_status.text='Komrade exists as a contact of yours.'
else:
await self.app.stat('Account does not exist on hardware, maybe not on server. Try to register?')
# await self.app.stat('Account does not exist on hardware, maybe not on server. Try to register?')
# self.login_status.text='Komrade not known on this device. Registering...'
### REGISTER
@ -218,9 +225,10 @@ class LoginScreen(BaseScreen):
if kommie.exists_locally_as_contact():
return {'success':False, 'status':'This is already a contact of yours'}
#
await logfunc(f'Hello, this is Komrade @{name}. I would like to join the socialist network.',pause=True,komrade_name=name)
await logfunc(f'Hello, this is Komrade @{name}.\n\nI would like to sign up for the socialist network revolution.',pause=True,komrade_name=name)
await logfunc(f'Excellent. But to communicate with komrades securely, you must first cut your public & private encryption keys.',pause=True,clear=True)
await logfunc(f'Welcome, Komrade @{name}. To help us communicate safely, I have cut for you a matching pair of encryption keys.',pause=True,clear=True,komrade_name='Keymaker')
# ## 2) Make pub public/private keys
from komrade.backend.keymaker import KomradeAsymmetricKey
@ -228,8 +236,22 @@ class LoginScreen(BaseScreen):
keypair = KomradeAsymmetricKey()
logger.info('cut keypair!')
pubkey,privkey = keypair.pubkey_obj,keypair.privkey_obj
await logfunc(f'I have cut for you a private and public asymmetric key pair, using the iron-clad Elliptic curve algorithm:',komrade_name='Keymaker')
await logfunc('(1) {pubkey}\n\n(2) {privkey}',clear=True,pause=True,komrade_name='Keymaker')
uri_id = pubkey.data_b64
uri_s = pubkey.data_b64_s
fnfn = kommie.save_uri_as_qrcode(uri_id=uri_id,name=name)
# await logfunc(f'Here. I have cut for you a private and public asymmetric key pair, using the iron-clad Elliptic curve algorithm:',komrade_name='Keymaker')
await logfunc(f'The first is your "public key", which you can share with anyone. With it, someone can write you an encrypted message.',komrade_name='Keymaker')
await logfunc(f'You can share it by pasting it to someone in a secure message:\n\n{uri_s}',komrade_name='Keymaker')
await logfunc(f'You can also share it IRL, phone to phone, as a QR code. This is what it will look like.',img_src=fnfn,komrade_name='Keymaker')
# await logfunc(f'(1) {pubkey} -- and -- (2) {privkey}',clear=True,pause=True,komrade_name='Keymaker')
# await logfunc(f'(1) You may store your public key both on your device hardware, as well as share it with anyone you wish: {pubkey.data_b64_s}') #\n\nIt will also be stored as a QR code on your device:\n{qr_str}',pause=True,clear=True)
kommie._keychain['pubkey']=pubkey
@ -241,10 +263,9 @@ class LoginScreen(BaseScreen):
### PRIVATE KEY
await logfunc(f"(2) Your PRIVATE key, on the other hand, must be stored only on your device hardware.",pause=True)
await logfunc('''Your private key is so sensitive we'll even encrypt it before storing it.''',pause=True,use_prefix=False)
### PRIVATE KEY
await logfunc(f"(2) Your PRIVATE encryption key, on the other hand, must be stored only on your device hardware. In fact it's so sensitive we'll even encrypt the encryption key itself.",pause=True,use_prefix=False)
passhash = hasher(passphrase)
privkey_decr = KomradeSymmetricKeyWithPassphrase(passhash=passhash)
@ -269,8 +290,6 @@ class LoginScreen(BaseScreen):
# ### PUBLIC KEY
qr_str=kommie.qr_str(pubkey.data_b64)
await logfunc(f'(1) You may store your public key both on your device hardware, as well as share it with anyone you wish:\n\n{pubkey.data_b64_s}') #\n\nIt will also be stored as a QR code on your device:\n{qr_str}',pause=True,clear=True)
await logfunc('You must also register your username and public key with Komrade @Operator on the remote server',pause=False,clear=False)

Loading…
Cancel
Save