toxygen/src/libtox.py

34 lines
967 B
Python
Raw Normal View History

2016-04-24 10:45:11 +00:00
from platform import system
from ctypes import CDLL
class LibToxCore(object):
def __init__(self):
if system() == 'Linux':
# be sure that libtoxcore and libsodium are installed in your os
self._libtoxcore = CDLL('libtoxcore.so')
elif system() == 'Windows':
self._libtoxcore = CDLL('libs/libtox.dll')
else:
raise OSError('Unknown system.')
def __getattr__(self, item):
return self._libtoxcore.__getattr__(item)
class LibToxAV(object):
def __init__(self):
if system() == 'Linux':
# be sure that /usr/lib/libtoxav.so exists
self._libtoxav = CDLL('libtoxav.so')
elif system() == 'Windows':
# on Windows av api is in libtox.dll
self._libtoxav = CDLL('libs/libtox.dll')
else:
raise OSError('Unknown system.')
def __getattr__(self, item):
return self._libtoxav.__getattr__(item)