profile loading/creation update, bug fixes
This commit is contained in:
parent
a4da3a7afa
commit
a714c1045d
@ -140,7 +140,7 @@ def friend_request(tox, public_key, message, message_size, user_data):
|
|||||||
key = ''.join(chr(x) for x in public_key[:TOX_PUBLIC_KEY_SIZE])
|
key = ''.join(chr(x) for x in public_key[:TOX_PUBLIC_KEY_SIZE])
|
||||||
tox_id = bin_to_string(key, TOX_PUBLIC_KEY_SIZE)
|
tox_id = bin_to_string(key, TOX_PUBLIC_KEY_SIZE)
|
||||||
if tox_id not in Settings.get_instance()['blocked']:
|
if tox_id not in Settings.get_instance()['blocked']:
|
||||||
invoke_in_main_thread(profile.process_friend_request, tox_id, message)
|
invoke_in_main_thread(profile.process_friend_request, tox_id, str(message, 'utf-8'))
|
||||||
|
|
||||||
|
|
||||||
def friend_typing(tox, friend_number, typing, user_data):
|
def friend_typing(tox, friend_number, typing, user_data):
|
||||||
|
@ -121,7 +121,7 @@ class SendTransfer(FileTransfer):
|
|||||||
super(SendTransfer, self).__init__(path, tox, friend_number, size)
|
super(SendTransfer, self).__init__(path, tox, friend_number, size)
|
||||||
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
|
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
|
||||||
self._file_number = tox.file_send(friend_number, kind, size, file_id,
|
self._file_number = tox.file_send(friend_number, kind, size, file_id,
|
||||||
bytes(basename(path), 'utf-8') if path else '')
|
bytes(basename(path), 'utf-8') if path else b'')
|
||||||
|
|
||||||
def send_chunk(self, position, size):
|
def send_chunk(self, position, size):
|
||||||
"""
|
"""
|
||||||
|
@ -83,7 +83,7 @@ class LoginScreen(CenteredWidget):
|
|||||||
|
|
||||||
def create_profile(self):
|
def create_profile(self):
|
||||||
self.type = 1
|
self.type = 1
|
||||||
self.name = self.new_name.toPlainText()
|
self.name = self.new_name.text()
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def load_ex_profile(self):
|
def load_ex_profile(self):
|
||||||
|
11
src/main.py
11
src/main.py
@ -11,7 +11,6 @@ from profile import tox_factory
|
|||||||
from callbacks import init_callbacks
|
from callbacks import init_callbacks
|
||||||
from util import curr_directory
|
from util import curr_directory
|
||||||
import styles.style
|
import styles.style
|
||||||
import locale
|
|
||||||
import toxencryptsave
|
import toxencryptsave
|
||||||
from passwordscreen import PasswordScreen
|
from passwordscreen import PasswordScreen
|
||||||
import profile
|
import profile
|
||||||
@ -62,8 +61,8 @@ class Toxygen:
|
|||||||
encrypt_save = toxencryptsave.LibToxEncryptSave()
|
encrypt_save = toxencryptsave.LibToxEncryptSave()
|
||||||
|
|
||||||
if self.path is not None:
|
if self.path is not None:
|
||||||
path = os.path.dirname(self.path.encode(locale.getpreferredencoding())) + '/'
|
path = os.path.dirname(self.path) + '/'
|
||||||
name = os.path.basename(self.path.encode(locale.getpreferredencoding()))[:-4]
|
name = os.path.basename(self.path)[:-4]
|
||||||
data = ProfileHelper(path, name).open_profile()
|
data = ProfileHelper(path, name).open_profile()
|
||||||
if encrypt_save.is_data_encrypted(data):
|
if encrypt_save.is_data_encrypted(data):
|
||||||
data = self.enter_pass(data)
|
data = self.enter_pass(data)
|
||||||
@ -94,10 +93,11 @@ class Toxygen:
|
|||||||
if not _login.t:
|
if not _login.t:
|
||||||
return
|
return
|
||||||
elif _login.t == 1: # create new profile
|
elif _login.t == 1: # create new profile
|
||||||
|
_login.name = _login.name.strip()
|
||||||
name = _login.name if _login.name else 'toxygen_user'
|
name = _login.name if _login.name else 'toxygen_user'
|
||||||
self.tox = tox_factory()
|
self.tox = tox_factory()
|
||||||
self.tox.self_set_name(_login.name if _login.name else 'Toxygen User')
|
self.tox.self_set_name(bytes(_login.name, 'utf-8') if _login.name else b'Toxygen User')
|
||||||
self.tox.self_set_status_message('Toxing on Toxygen')
|
self.tox.self_set_status_message(b'Toxing on Toxygen')
|
||||||
ProfileHelper(Settings.get_default_path(), name).save_profile(self.tox.get_savedata())
|
ProfileHelper(Settings.get_default_path(), name).save_profile(self.tox.get_savedata())
|
||||||
path = Settings.get_default_path()
|
path = Settings.get_default_path()
|
||||||
settings = Settings(name)
|
settings = Settings(name)
|
||||||
@ -112,7 +112,6 @@ class Toxygen:
|
|||||||
self.tox = tox_factory(data, settings)
|
self.tox = tox_factory(data, settings)
|
||||||
else:
|
else:
|
||||||
path, name = auto_profile
|
path, name = auto_profile
|
||||||
path = path.encode(locale.getpreferredencoding())
|
|
||||||
data = ProfileHelper(path, name).open_profile()
|
data = ProfileHelper(path, name).open_profile()
|
||||||
if encrypt_save.is_data_encrypted(data):
|
if encrypt_save.is_data_encrypted(data):
|
||||||
data = self.enter_pass(data)
|
data = self.enter_pass(data)
|
||||||
|
@ -22,8 +22,8 @@ def tox_dns(email):
|
|||||||
def send_request(url, data):
|
def send_request(url, data):
|
||||||
req = urllib.request.Request(url)
|
req = urllib.request.Request(url)
|
||||||
req.add_header('Content-Type', 'application/json')
|
req.add_header('Content-Type', 'application/json')
|
||||||
response = urllib.request.urlopen(req, json.dumps(data))
|
response = urllib.request.urlopen(req, bytes(json.dumps(data), 'utf-8'))
|
||||||
res = json.loads(response.read())
|
res = json.loads(str(response.read(), 'utf-8'))
|
||||||
if not res['c']:
|
if not res['c']:
|
||||||
return res['tox_id']
|
return res['tox_id']
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user