updates of main.py, util and bootstrap
This commit is contained in:
parent
fe43a4d03d
commit
a9837a80f4
3 changed files with 12 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
import util
|
from util import string_to_bin
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ class Node(object):
|
||||||
self._ip, self._port, self._tox_key, self.rand = ip, port, tox_key, rand
|
self._ip, self._port, self._tox_key, self.rand = ip, port, tox_key, rand
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
# TODO: return tox_key in binary format
|
return self._ip, self._port, string_to_bin(self._tox_key)
|
||||||
return self._ip, self._port, self._tox_key
|
|
||||||
|
|
||||||
|
|
||||||
def node_generator():
|
def node_generator():
|
||||||
|
|
11
src/main.py
11
src/main.py
|
@ -5,6 +5,7 @@ from profile import Profile
|
||||||
import sys
|
import sys
|
||||||
from PySide import QtCore, QtGui
|
from PySide import QtCore, QtGui
|
||||||
from tox import Tox
|
from tox import Tox
|
||||||
|
from bootstrap import node_generator
|
||||||
|
|
||||||
|
|
||||||
class login(object):
|
class login(object):
|
||||||
|
@ -34,6 +35,10 @@ def status(a, b, c):
|
||||||
print str(b)
|
print str(b)
|
||||||
|
|
||||||
|
|
||||||
|
def friend_status(*args):
|
||||||
|
print 'Friend connected! Friend number: ' + str(args[1])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
main function of app. loads loginscreen if needed and starts mainscreen
|
main function of app. loads loginscreen if needed and starts mainscreen
|
||||||
|
@ -72,8 +77,12 @@ def main():
|
||||||
ms = MainWindow()
|
ms = MainWindow()
|
||||||
# creating tox instance
|
# creating tox instance
|
||||||
tox = Tox(data, settings)
|
tox = Tox(data, settings)
|
||||||
|
# bootstrap
|
||||||
|
for data in node_generator():
|
||||||
|
tox.bootstrap(*data)
|
||||||
# TODO: set callbacks
|
# TODO: set callbacks
|
||||||
#tox.callback_self_connection_status(status, 0)
|
tox.callback_self_connection_status(status, 0)
|
||||||
|
tox.callback_friend_connection_status(friend_status, 0)
|
||||||
# starting thread for tox iterate
|
# starting thread for tox iterate
|
||||||
mainloop = ToxIterateThread(tox)
|
mainloop = ToxIterateThread(tox)
|
||||||
mainloop.start()
|
mainloop.start()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# TODO: add string to bin and bin to string (TOX ID) (and DHT connection?)
|
|
||||||
|
|
||||||
|
|
||||||
def log(data):
|
def log(data):
|
||||||
|
@ -13,4 +12,3 @@ def string_to_bin(tox_id):
|
||||||
def bin_to_string(raw_id):
|
def bin_to_string(raw_id):
|
||||||
res = ''.join('{:02x}'.format(ord(x)) for x in raw_id)
|
res = ''.join('{:02x}'.format(ord(x)) for x in raw_id)
|
||||||
return res.upper()
|
return res.upper()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue