toxygen/toxygen/libtox.py

60 lines
1.9 KiB
Python
Raw Normal View History

2016-04-24 10:45:11 +00:00
from platform import system
from ctypes import CDLL
2016-06-22 13:09:44 +00:00
import util
2016-04-24 10:45:11 +00:00
2016-06-22 11:35:22 +00:00
class LibToxCore:
2016-04-24 10:45:11 +00:00
def __init__(self):
2016-07-27 11:50:36 +00:00
if system() == 'Windows':
2016-06-22 13:09:44 +00:00
self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
elif system() == 'Darwin':
self._libtoxcore = CDLL('libtoxcore.dylib')
2016-04-24 10:45:11 +00:00
else:
2016-07-27 11:50:36 +00:00
# libtoxcore and libsodium must be installed in your os
try:
self._libtoxcore = CDLL('libtoxcore.so')
except:
self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtoxcore.so')
2016-04-24 10:45:11 +00:00
def __getattr__(self, item):
return self._libtoxcore.__getattr__(item)
2016-06-22 11:35:22 +00:00
class LibToxAV:
2016-04-24 10:45:11 +00:00
def __init__(self):
2016-07-27 11:50:36 +00:00
if system() == 'Windows':
2016-04-24 10:45:11 +00:00
# on Windows av api is in libtox.dll
2016-06-22 13:09:44 +00:00
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
elif system() == 'Darwin':
self._libtoxav = CDLL('libtoxav.dylib')
2016-04-24 10:45:11 +00:00
else:
2016-07-27 11:50:36 +00:00
# /usr/lib/libtoxav.so must exists
try:
self._libtoxav = CDLL('libtoxav.so')
except:
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtoxav.so')
2016-04-24 10:45:11 +00:00
def __getattr__(self, item):
return self._libtoxav.__getattr__(item)
2016-05-14 09:29:54 +00:00
2016-06-22 11:35:22 +00:00
class LibToxEncryptSave:
2016-05-14 09:29:54 +00:00
def __init__(self):
2016-07-27 11:50:36 +00:00
if system() == 'Windows':
2016-05-14 09:29:54 +00:00
# on Windows profile encryption api is in libtox.dll
2016-06-22 13:09:44 +00:00
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
elif system() == 'Darwin':
self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.dylib')
2016-05-14 09:29:54 +00:00
else:
2016-07-27 11:50:36 +00:00
# /usr/lib/libtoxencryptsave.so must exists
try:
self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
except:
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtoxencryptsave.so')
2016-05-14 09:29:54 +00:00
def __getattr__(self, item):
return self._lib_tox_encrypt_save.__getattr__(item)