toxygen/src/libtox.py

51 lines
1.5 KiB
Python
Raw Normal View History

2016-04-24 12:45:11 +02:00
from platform import system
from ctypes import CDLL
2016-06-22 15:09:44 +02:00
import util
2016-04-24 12:45:11 +02:00
2016-06-22 13:35:22 +02:00
class LibToxCore:
2016-04-24 12:45:11 +02:00
def __init__(self):
if system() == 'Linux':
2016-05-14 11:29:54 +02:00
# libtoxcore and libsodium must be installed in your os
2016-04-24 12:45:11 +02:00
self._libtoxcore = CDLL('libtoxcore.so')
elif system() == 'Windows':
2016-06-22 15:09:44 +02:00
self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
2016-04-24 12:45:11 +02:00
else:
raise OSError('Unknown system.')
def __getattr__(self, item):
return self._libtoxcore.__getattr__(item)
2016-06-22 13:35:22 +02:00
class LibToxAV:
2016-04-24 12:45:11 +02:00
def __init__(self):
if system() == 'Linux':
2016-05-14 11:29:54 +02:00
# that /usr/lib/libtoxav.so must exists
2016-04-24 12:45:11 +02:00
self._libtoxav = CDLL('libtoxav.so')
elif system() == 'Windows':
# on Windows av api is in libtox.dll
2016-06-22 15:09:44 +02:00
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
2016-04-24 12:45:11 +02:00
else:
raise OSError('Unknown system.')
def __getattr__(self, item):
return self._libtoxav.__getattr__(item)
2016-05-14 11:29:54 +02:00
2016-06-22 13:35:22 +02:00
class LibToxEncryptSave:
2016-05-14 11:29:54 +02:00
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
2016-06-22 15:09:44 +02:00
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
2016-05-14 11:29:54 +02:00
else:
raise OSError('Unknown system.')
def __getattr__(self, item):
return self._lib_tox_encrypt_save.__getattr__(item)