profile loading/creation update, bug fixes

This commit is contained in:
ingvar1995 2016-06-23 15:04:36 +03:00
parent a4da3a7afa
commit a714c1045d
5 changed files with 10 additions and 11 deletions

View file

@ -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])
tox_id = bin_to_string(key, TOX_PUBLIC_KEY_SIZE)
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):

View file

@ -121,7 +121,7 @@ class SendTransfer(FileTransfer):
super(SendTransfer, self).__init__(path, tox, friend_number, size)
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
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):
"""

View file

@ -83,7 +83,7 @@ class LoginScreen(CenteredWidget):
def create_profile(self):
self.type = 1
self.name = self.new_name.toPlainText()
self.name = self.new_name.text()
self.close()
def load_ex_profile(self):

View file

@ -11,7 +11,6 @@ from profile import tox_factory
from callbacks import init_callbacks
from util import curr_directory
import styles.style
import locale
import toxencryptsave
from passwordscreen import PasswordScreen
import profile
@ -62,8 +61,8 @@ class Toxygen:
encrypt_save = toxencryptsave.LibToxEncryptSave()
if self.path is not None:
path = os.path.dirname(self.path.encode(locale.getpreferredencoding())) + '/'
name = os.path.basename(self.path.encode(locale.getpreferredencoding()))[:-4]
path = os.path.dirname(self.path) + '/'
name = os.path.basename(self.path)[:-4]
data = ProfileHelper(path, name).open_profile()
if encrypt_save.is_data_encrypted(data):
data = self.enter_pass(data)
@ -94,10 +93,11 @@ class Toxygen:
if not _login.t:
return
elif _login.t == 1: # create new profile
_login.name = _login.name.strip()
name = _login.name if _login.name else 'toxygen_user'
self.tox = tox_factory()
self.tox.self_set_name(_login.name if _login.name else 'Toxygen User')
self.tox.self_set_status_message('Toxing on Toxygen')
self.tox.self_set_name(bytes(_login.name, 'utf-8') if _login.name else b'Toxygen User')
self.tox.self_set_status_message(b'Toxing on Toxygen')
ProfileHelper(Settings.get_default_path(), name).save_profile(self.tox.get_savedata())
path = Settings.get_default_path()
settings = Settings(name)
@ -112,7 +112,6 @@ class Toxygen:
self.tox = tox_factory(data, settings)
else:
path, name = auto_profile
path = path.encode(locale.getpreferredencoding())
data = ProfileHelper(path, name).open_profile()
if encrypt_save.is_data_encrypted(data):
data = self.enter_pass(data)

View file

@ -22,8 +22,8 @@ def tox_dns(email):
def send_request(url, data):
req = urllib.request.Request(url)
req.add_header('Content-Type', 'application/json')
response = urllib.request.urlopen(req, json.dumps(data))
res = json.loads(response.read())
response = urllib.request.urlopen(req, bytes(json.dumps(data), 'utf-8'))
res = json.loads(str(response.read(), 'utf-8'))
if not res['c']:
return res['tox_id']
else: