profile creation added
This commit is contained in:
parent
6819698596
commit
9145974c7f
17
src/main.py
17
src/main.py
@ -52,23 +52,24 @@ def main():
|
||||
if not _login.t:
|
||||
return
|
||||
elif _login.t == 1: # create new profile
|
||||
# TODO: add possibility to create new profile
|
||||
path = Settings.get_default_path()
|
||||
# TODO: test
|
||||
name = _login.name if _login.name else 'Toxygen User'
|
||||
return
|
||||
tox = tox_factory()
|
||||
tox.self_set_name(name)
|
||||
Profile.save_profile(tox.get_savedata())
|
||||
else: # load existing profile
|
||||
path, name = _login.get_data()
|
||||
if _login.default:
|
||||
settings['auto_profile'] = (path, name)
|
||||
settings.save()
|
||||
data = Profile.open_profile(path, name)
|
||||
tox = tox_factory(data, settings)
|
||||
else:
|
||||
path, name = settings['auto_profile']
|
||||
# loading profile
|
||||
print str(path), str(name)
|
||||
data = Profile.open_profile(path, name)
|
||||
data = Profile.open_profile(path, name)
|
||||
tox = tox_factory(data, settings)
|
||||
|
||||
ms = MainWindow()
|
||||
# creating tox instance
|
||||
tox = tox_factory(data, settings)
|
||||
ms.show()
|
||||
# bootstrap
|
||||
for data in node_generator():
|
||||
|
@ -37,12 +37,16 @@ class Profile(object):
|
||||
|
||||
@staticmethod
|
||||
def save_profile(data):
|
||||
if not hasattr(Profile, '_path'):
|
||||
Profile._path = Settings.get_default_path()
|
||||
with open(Profile._path, 'wb') as fl:
|
||||
fl.write(data)
|
||||
print 'Data saved to: {}'.format(Profile._path)
|
||||
|
||||
|
||||
def tox_factory(data, settings):
|
||||
def tox_factory(data=None, settings=None):
|
||||
if settings is None:
|
||||
settings = Settings.get_default_settings()
|
||||
tox_options = Tox.options_new()
|
||||
tox_options.contents.udp_enabled = settings['udp_enabled']
|
||||
tox_options.contents.proxy_type = settings['proxy_type']
|
||||
@ -51,7 +55,12 @@ def tox_factory(data, settings):
|
||||
tox_options.contents.start_port = settings['start_port']
|
||||
tox_options.contents.end_port = settings['end_port']
|
||||
tox_options.contents.tcp_port = settings['tcp_port']
|
||||
tox_options.contents.savedata_type = TOX_SAVEDATA_TYPE['TOX_SAVE']
|
||||
tox_options.contents.savedata_data = c_char_p(data)
|
||||
tox_options.contents.savedata_length = len(data)
|
||||
if data: # load existing profile
|
||||
tox_options.contents.savedata_type = TOX_SAVEDATA_TYPE['TOX_SAVE']
|
||||
tox_options.contents.savedata_data = c_char_p(data)
|
||||
tox_options.contents.savedata_length = len(data)
|
||||
else: # create new profile
|
||||
tox_options.contents.savedata_type = TOX_SAVEDATA_TYPE['NONE']
|
||||
tox_options.contents.savedata_data = None
|
||||
tox_options.contents.savedata_length = 0
|
||||
return Tox(tox_options)
|
||||
|
Loading…
Reference in New Issue
Block a user