Start
This commit is contained in:
parent
f0cdfc5d1c
commit
a8d50bb699
5 changed files with 63 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,3 +3,5 @@
|
||||||
*.ui
|
*.ui
|
||||||
src/toxcore
|
src/toxcore
|
||||||
src/libs
|
src/libs
|
||||||
|
.idea
|
||||||
|
*~
|
||||||
|
|
0
src/profile.py
Normal file
0
src/profile.py
Normal file
22
src/settings.py
Normal file
22
src/settings.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import getpass
|
||||||
|
import platform
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
path = Settings.get_default_path() + 'toxygen.json'
|
||||||
|
with open(path) as fl:
|
||||||
|
data = fl.read()
|
||||||
|
self.data = json.loads(data)
|
||||||
|
|
||||||
|
def __get__(self, attr):
|
||||||
|
return self.data[attr]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_default_path():
|
||||||
|
name = platform.system()
|
||||||
|
if name == 'Linux':
|
||||||
|
user = getpass.getuser()
|
||||||
|
return '/home/{}/.config/tox/'.format(user)
|
39
src/tox.py
Normal file
39
src/tox.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
from ctypes import *
|
||||||
|
from settings import Settings
|
||||||
|
|
||||||
|
|
||||||
|
class ToxOptions(Structure):
|
||||||
|
_fields_ = [
|
||||||
|
("ipv6_enabled", c_bool),
|
||||||
|
("udp_enabled", c_bool),
|
||||||
|
("proxy_type", c_int),
|
||||||
|
("proxy_host", c_char_p),
|
||||||
|
("proxy_port", c_uint16),
|
||||||
|
("start_port", c_uint16),
|
||||||
|
("end_port", c_uint16),
|
||||||
|
("tcp_port", c_uint16),
|
||||||
|
("savedata_type", c_int),
|
||||||
|
("savedata_data", POINTER(c_uint8)),
|
||||||
|
("savedata_length", c_size_t)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class Tox(object):
|
||||||
|
|
||||||
|
def __init__(self, name):
|
||||||
|
path = Settings.get_default_path() + name + '.tox'
|
||||||
|
with open(path, 'rb') as fl:
|
||||||
|
data = fl.read()
|
||||||
|
size = len(data)
|
||||||
|
print size
|
||||||
|
libtoxcore = CDLL('libtoxcore.so')
|
||||||
|
libtoxcore.tox_options_new.restype = POINTER(ToxOptions)
|
||||||
|
self.tox_options = libtoxcore.tox_options_new(0)
|
||||||
|
libtoxcore.tox_new.restype = POINTER(c_void_p)
|
||||||
|
tox = libtoxcore.tox_new(None, None)
|
||||||
|
self.libtoxcore = libtoxcore
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
t = Tox('tox_save')
|
||||||
|
|
||||||
|
|
0
tests/tests.py
Normal file
0
tests/tests.py
Normal file
Loading…
Reference in a new issue