toxencryptsave lib loading

This commit is contained in:
ingvar1995 2016-05-14 12:29:54 +03:00
parent f445a79e11
commit b0e1aeb0f0
3 changed files with 36 additions and 2 deletions

View file

@ -6,7 +6,7 @@ class LibToxCore(object):
def __init__(self): def __init__(self):
if system() == 'Linux': if system() == 'Linux':
# be sure that libtoxcore and libsodium are installed in your os # libtoxcore and libsodium must be installed in your os
self._libtoxcore = CDLL('libtoxcore.so') self._libtoxcore = CDLL('libtoxcore.so')
elif system() == 'Windows': elif system() == 'Windows':
self._libtoxcore = CDLL('libs/libtox.dll') self._libtoxcore = CDLL('libs/libtox.dll')
@ -21,7 +21,7 @@ class LibToxAV(object):
def __init__(self): def __init__(self):
if system() == 'Linux': if system() == 'Linux':
# be sure that /usr/lib/libtoxav.so exists # that /usr/lib/libtoxav.so must exists
self._libtoxav = CDLL('libtoxav.so') self._libtoxav = CDLL('libtoxav.so')
elif system() == 'Windows': elif system() == 'Windows':
# on Windows av api is in libtox.dll # on Windows av api is in libtox.dll
@ -31,3 +31,19 @@ class LibToxAV(object):
def __getattr__(self, item): def __getattr__(self, item):
return self._libtoxav.__getattr__(item) return self._libtoxav.__getattr__(item)
class LibToxEncryptSave(object):
def __init__(self):
if system() == 'Linux':
# /usr/lib/libtoxencryptsave.so must exists
self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
elif system() == 'Windows':
# on Windows profile encryption api is in libtox.dll
self._lib_tox_encrypt_save = CDLL('libs/libtox.dll')
else:
raise OSError('Unknown system.')
def __getattr__(self, item):
return self._lib_tox_encrypt_save.__getattr__(item)

View file

@ -136,6 +136,7 @@ class Settings(Singleton, dict):
return os.getenv('APPDATA') + '/Tox/' return os.getenv('APPDATA') + '/Tox/'
# TODO: singleton (with encryption)
class ProfileHelper(object): class ProfileHelper(object):
""" """
Class with static methods for search, load and save profiles Class with static methods for search, load and save profiles

17
src/toxencryptsave.py Normal file
View file

@ -0,0 +1,17 @@
import libtox
import util
# TODO: add enums and methods
class LibToxEncryptSave(util.Singleton):
libtoxencryptsave = libtox.LibToxEncryptSave()
def __init__(self, password=''):
self._password = password
def set_password(self, value):
self._password = value