rebased ngc - initial commit
This commit is contained in:
parent
03e2fa4cb8
commit
74a5f95a56
@ -1 +1 @@
|
|||||||
{"nodes":[{"ipv4":"127.0.0.1","ipv6":"-","port":33445,"public_key":"617DA0076546F9A801D06AAA2E20234DA6A1DDA90583FB02B59E3501CA84D061","status_udp":true,"status_tcp":true}]}
|
{"nodes":[{"ipv4":"127.0.0.1","ipv6":"-","port":33445,"public_key":"82B9E28CF62A2D78D83BAC452CD18778F1F36B7BDF2989A3B8927D86D09C2E3D","status_udp":true,"status_tcp":true}]}
|
@ -1,6 +1,4 @@
|
|||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
from user_data.settings import Settings
|
|
||||||
from contacts.profile import Profile
|
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from wrapper.toxcore_enums_and_consts import *
|
||||||
from wrapper.toxav_enums import *
|
from wrapper.toxav_enums import *
|
||||||
from wrapper.tox import bin_to_string
|
from wrapper.tox import bin_to_string
|
||||||
@ -22,7 +20,7 @@ import threading
|
|||||||
|
|
||||||
def self_connection_status(tox, profile):
|
def self_connection_status(tox, profile):
|
||||||
"""
|
"""
|
||||||
Current user changed connection status (offline, UDP, TCP)
|
Current user changed connection status (offline, TCP, UDP)
|
||||||
"""
|
"""
|
||||||
def wrapped(tox_link, connection, user_data):
|
def wrapped(tox_link, connection, user_data):
|
||||||
print('Connection status: ', str(connection))
|
print('Connection status: ', str(connection))
|
||||||
@ -103,7 +101,7 @@ def friend_status_message(contacts_manager, messenger):
|
|||||||
"""
|
"""
|
||||||
friend = contacts_manager.get_friend_by_number(friend_number)
|
friend = contacts_manager.get_friend_by_number(friend_number)
|
||||||
invoke_in_main_thread(friend.set_status_message, str(status_message, 'utf-8'))
|
invoke_in_main_thread(friend.set_status_message, str(status_message, 'utf-8'))
|
||||||
print('User #{} has new status'.format(friend_number))
|
print('User #{} has new status message'.format(friend_number))
|
||||||
invoke_in_main_thread(messenger.send_messages, friend_number)
|
invoke_in_main_thread(messenger.send_messages, friend_number)
|
||||||
|
|
||||||
return wrapped
|
return wrapped
|
||||||
@ -472,25 +470,25 @@ def init_callbacks(tox, profile, settings, plugin_loader, contacts_manager,
|
|||||||
:param contacts_provider: ContactsProvider instance
|
:param contacts_provider: ContactsProvider instance
|
||||||
"""
|
"""
|
||||||
# self callbacks
|
# self callbacks
|
||||||
tox.callback_self_connection_status(self_connection_status(tox, profile), 0)
|
tox.callback_self_connection_status(self_connection_status(tox, profile))
|
||||||
|
|
||||||
# friend callbacks
|
# friend callbacks
|
||||||
tox.callback_friend_status(friend_status(contacts_manager, file_transfer_handler, profile, settings), 0)
|
tox.callback_friend_status(friend_status(contacts_manager, file_transfer_handler, profile, settings))
|
||||||
tox.callback_friend_message(friend_message(messenger, contacts_manager, profile, settings, main_window, tray), 0)
|
tox.callback_friend_message(friend_message(messenger, contacts_manager, profile, settings, main_window, tray))
|
||||||
tox.callback_friend_connection_status(friend_connection_status(contacts_manager, profile, settings, plugin_loader,
|
tox.callback_friend_connection_status(friend_connection_status(contacts_manager, profile, settings, plugin_loader,
|
||||||
file_transfer_handler, messenger, calls_manager), 0)
|
file_transfer_handler, messenger, calls_manager))
|
||||||
tox.callback_friend_name(friend_name(contacts_provider, messenger), 0)
|
tox.callback_friend_name(friend_name(contacts_provider, messenger))
|
||||||
tox.callback_friend_status_message(friend_status_message(contacts_manager, messenger), 0)
|
tox.callback_friend_status_message(friend_status_message(contacts_manager, messenger))
|
||||||
tox.callback_friend_request(friend_request(contacts_manager), 0)
|
tox.callback_friend_request(friend_request(contacts_manager))
|
||||||
tox.callback_friend_typing(friend_typing(messenger), 0)
|
tox.callback_friend_typing(friend_typing(messenger))
|
||||||
tox.callback_friend_read_receipt(friend_read_receipt(messenger), 0)
|
tox.callback_friend_read_receipt(friend_read_receipt(messenger))
|
||||||
|
|
||||||
# file transfer
|
# file transfer
|
||||||
tox.callback_file_recv(tox_file_recv(main_window, tray, profile, file_transfer_handler,
|
tox.callback_file_recv(tox_file_recv(main_window, tray, profile, file_transfer_handler,
|
||||||
contacts_manager, settings), 0)
|
contacts_manager, settings))
|
||||||
tox.callback_file_recv_chunk(file_recv_chunk(file_transfer_handler), 0)
|
tox.callback_file_recv_chunk(file_recv_chunk(file_transfer_handler))
|
||||||
tox.callback_file_chunk_request(file_chunk_request(file_transfer_handler), 0)
|
tox.callback_file_chunk_request(file_chunk_request(file_transfer_handler))
|
||||||
tox.callback_file_recv_control(file_recv_control(file_transfer_handler), 0)
|
tox.callback_file_recv_control(file_recv_control(file_transfer_handler))
|
||||||
|
|
||||||
# av
|
# av
|
||||||
toxav = tox.AV
|
toxav = tox.AV
|
||||||
@ -500,8 +498,8 @@ def init_callbacks(tox, profile, settings, plugin_loader, contacts_manager,
|
|||||||
toxav.callback_video_receive_frame(video_receive_frame, 0)
|
toxav.callback_video_receive_frame(video_receive_frame, 0)
|
||||||
|
|
||||||
# custom packets
|
# custom packets
|
||||||
tox.callback_friend_lossless_packet(lossless_packet(plugin_loader), 0)
|
tox.callback_friend_lossless_packet(lossless_packet(plugin_loader))
|
||||||
tox.callback_friend_lossy_packet(lossy_packet(plugin_loader), 0)
|
tox.callback_friend_lossy_packet(lossy_packet(plugin_loader))
|
||||||
|
|
||||||
# gc callbacks
|
# gc callbacks
|
||||||
tox.callback_group_message(group_message(main_window, tray, tox, messenger, settings, profile), 0)
|
tox.callback_group_message(group_message(main_window, tray, tox, messenger, settings, profile), 0)
|
||||||
|
@ -21,6 +21,7 @@ def tox_factory(data=None, settings=None):
|
|||||||
tox_options.contents.start_port = settings['start_port']
|
tox_options.contents.start_port = settings['start_port']
|
||||||
tox_options.contents.end_port = settings['end_port']
|
tox_options.contents.end_port = settings['end_port']
|
||||||
tox_options.contents.tcp_port = settings['tcp_port']
|
tox_options.contents.tcp_port = settings['tcp_port']
|
||||||
|
tox_options.contents.local_discovery_enabled = settings['lan_discovery']
|
||||||
if data: # load existing profile
|
if data: # load existing profile
|
||||||
tox_options.contents.savedata_type = enums.TOX_SAVEDATA_TYPE['TOX_SAVE']
|
tox_options.contents.savedata_type = enums.TOX_SAVEDATA_TYPE['TOX_SAVE']
|
||||||
tox_options.contents.savedata_data = ctypes.c_char_p(data)
|
tox_options.contents.savedata_data = ctypes.c_char_p(data)
|
||||||
|
@ -147,7 +147,8 @@ class Settings(dict):
|
|||||||
'update': 1,
|
'update': 1,
|
||||||
'group_notifications': True,
|
'group_notifications': True,
|
||||||
'download_nodes_list': False,
|
'download_nodes_list': False,
|
||||||
'notify_all_gc': False
|
'notify_all_gc': False,
|
||||||
|
'lan_discovery': True
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -28,13 +28,13 @@ class LibToxAV:
|
|||||||
# on Windows av api is in libtox.dll
|
# on Windows av api is in libtox.dll
|
||||||
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
|
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
|
||||||
elif system() == 'Darwin':
|
elif system() == 'Darwin':
|
||||||
self._libtoxav = CDLL('libtoxav.dylib')
|
self._libtoxav = CDLL('libtoxcore.dylib')
|
||||||
else:
|
else:
|
||||||
# /usr/lib/libtoxav.so must exists
|
# /usr/lib/libtoxcore.so must exists
|
||||||
try:
|
try:
|
||||||
self._libtoxav = CDLL('libtoxav.so')
|
self._libtoxav = CDLL('libtoxcore.so')
|
||||||
except:
|
except:
|
||||||
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtoxav.so')
|
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtoxcore.so')
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
return self._libtoxav.__getattr__(item)
|
return self._libtoxav.__getattr__(item)
|
||||||
@ -47,13 +47,13 @@ class LibToxEncryptSave:
|
|||||||
# on Windows profile encryption api is in libtox.dll
|
# on Windows profile encryption api is in libtox.dll
|
||||||
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
|
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
|
||||||
elif system() == 'Darwin':
|
elif system() == 'Darwin':
|
||||||
self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.dylib')
|
self._lib_tox_encrypt_save = CDLL('libtoxcore.dylib')
|
||||||
else:
|
else:
|
||||||
# /usr/lib/libtoxencryptsave.so must exists
|
# /usr/lib/libtoxcore.so must exists
|
||||||
try:
|
try:
|
||||||
self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
|
self._lib_tox_encrypt_save = CDLL('libtoxcore.so')
|
||||||
except:
|
except:
|
||||||
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtoxencryptsave.so')
|
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtoxcore.so')
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
return self._lib_tox_encrypt_save.__getattr__(item)
|
return self._lib_tox_encrypt_save.__getattr__(item)
|
||||||
|
@ -10,15 +10,19 @@ class ToxOptions(Structure):
|
|||||||
_fields_ = [
|
_fields_ = [
|
||||||
('ipv6_enabled', c_bool),
|
('ipv6_enabled', c_bool),
|
||||||
('udp_enabled', c_bool),
|
('udp_enabled', c_bool),
|
||||||
|
('local_discovery_enabled', c_bool),
|
||||||
('proxy_type', c_int),
|
('proxy_type', c_int),
|
||||||
('proxy_host', c_char_p),
|
('proxy_host', c_char_p),
|
||||||
('proxy_port', c_uint16),
|
('proxy_port', c_uint16),
|
||||||
('start_port', c_uint16),
|
('start_port', c_uint16),
|
||||||
('end_port', c_uint16),
|
('end_port', c_uint16),
|
||||||
('tcp_port', c_uint16),
|
('tcp_port', c_uint16),
|
||||||
|
('hole_punching_enabled', c_bool),
|
||||||
('savedata_type', c_int),
|
('savedata_type', c_int),
|
||||||
('savedata_data', c_char_p),
|
('savedata_data', c_char_p),
|
||||||
('savedata_length', c_size_t)
|
('savedata_length', c_size_t),
|
||||||
|
('log_callback', c_void_p),
|
||||||
|
('log_user_data', c_void_p)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -265,7 +269,7 @@ class Tox:
|
|||||||
"""
|
"""
|
||||||
return Tox.libtoxcore.tox_self_get_connection_status(self._tox_pointer)
|
return Tox.libtoxcore.tox_self_get_connection_status(self._tox_pointer)
|
||||||
|
|
||||||
def callback_self_connection_status(self, callback, user_data):
|
def callback_self_connection_status(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `self_connection_status` event. Pass None to unset.
|
Set the callback for the `self_connection_status` event. Pass None to unset.
|
||||||
|
|
||||||
@ -276,12 +280,11 @@ class Tox:
|
|||||||
:param callback: Python function. Should take pointer (c_void_p) to Tox object,
|
:param callback: Python function. Should take pointer (c_void_p) to Tox object,
|
||||||
TOX_CONNECTION (c_int),
|
TOX_CONNECTION (c_int),
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_void_p)
|
||||||
self.self_connection_status_cb = c_callback(callback)
|
self.self_connection_status_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_self_connection_status(self._tox_pointer,
|
Tox.libtoxcore.tox_callback_self_connection_status(self._tox_pointer,
|
||||||
self.self_connection_status_cb, user_data)
|
self.self_connection_status_cb)
|
||||||
|
|
||||||
def iteration_interval(self):
|
def iteration_interval(self):
|
||||||
"""
|
"""
|
||||||
@ -290,11 +293,13 @@ class Tox:
|
|||||||
"""
|
"""
|
||||||
return Tox.libtoxcore.tox_iteration_interval(self._tox_pointer)
|
return Tox.libtoxcore.tox_iteration_interval(self._tox_pointer)
|
||||||
|
|
||||||
def iterate(self):
|
def iterate(self, user_data=None):
|
||||||
"""
|
"""
|
||||||
The main loop that needs to be run in intervals of tox_iteration_interval() milliseconds.
|
The main loop that needs to be run in intervals of tox_iteration_interval() milliseconds.
|
||||||
"""
|
"""
|
||||||
Tox.libtoxcore.tox_iterate(self._tox_pointer)
|
if user_data is not None:
|
||||||
|
user_data = c_char_p(user_data)
|
||||||
|
Tox.libtoxcore.tox_iterate(self._tox_pointer, user_data)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Internal client information (Tox address/id)
|
# Internal client information (Tox address/id)
|
||||||
@ -719,7 +724,7 @@ class Tox:
|
|||||||
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
||||||
raise ArgumentError('The friend_number did not designate a valid friend.')
|
raise ArgumentError('The friend_number did not designate a valid friend.')
|
||||||
|
|
||||||
def callback_friend_name(self, callback, user_data):
|
def callback_friend_name(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_name` event. Pass None to unset.
|
Set the callback for the `friend_name` event. Pass None to unset.
|
||||||
|
|
||||||
@ -730,11 +735,10 @@ class Tox:
|
|||||||
A byte array (c_char_p) containing the same data as tox_friend_get_name would write to its `name` parameter,
|
A byte array (c_char_p) containing the same data as tox_friend_get_name would write to its `name` parameter,
|
||||||
A value (c_size_t) equal to the return value of tox_friend_get_name_size,
|
A value (c_size_t) equal to the return value of tox_friend_get_name_size,
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_char_p, c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_char_p, c_size_t, c_void_p)
|
||||||
self.friend_name_cb = c_callback(callback)
|
self.friend_name_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_name(self._tox_pointer, self.friend_name_cb, user_data)
|
Tox.libtoxcore.tox_callback_friend_name(self._tox_pointer, self.friend_name_cb)
|
||||||
|
|
||||||
def friend_get_status_message_size(self, friend_number):
|
def friend_get_status_message_size(self, friend_number):
|
||||||
"""
|
"""
|
||||||
@ -783,7 +787,7 @@ class Tox:
|
|||||||
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
||||||
raise ArgumentError('The friend_number did not designate a valid friend.')
|
raise ArgumentError('The friend_number did not designate a valid friend.')
|
||||||
|
|
||||||
def callback_friend_status_message(self, callback, user_data):
|
def callback_friend_status_message(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_status_message` event. Pass NULL to unset.
|
Set the callback for the `friend_status_message` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -795,12 +799,11 @@ class Tox:
|
|||||||
`status_message` parameter,
|
`status_message` parameter,
|
||||||
A value (c_size_t) equal to the return value of tox_friend_get_status_message_size,
|
A value (c_size_t) equal to the return value of tox_friend_get_status_message_size,
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_char_p, c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_char_p, c_size_t, c_void_p)
|
||||||
self.friend_status_message_cb = c_callback(callback)
|
self.friend_status_message_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_status_message(self._tox_pointer,
|
Tox.libtoxcore.tox_callback_friend_status_message(self._tox_pointer,
|
||||||
self.friend_status_message_cb, c_void_p(user_data))
|
self.friend_status_message_cb)
|
||||||
|
|
||||||
def friend_get_status(self, friend_number):
|
def friend_get_status(self, friend_number):
|
||||||
"""
|
"""
|
||||||
@ -824,7 +827,7 @@ class Tox:
|
|||||||
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
||||||
raise ArgumentError('The friend_number did not designate a valid friend.')
|
raise ArgumentError('The friend_number did not designate a valid friend.')
|
||||||
|
|
||||||
def callback_friend_status(self, callback, user_data):
|
def callback_friend_status(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_status` event. Pass None to unset.
|
Set the callback for the `friend_status` event. Pass None to unset.
|
||||||
|
|
||||||
@ -838,7 +841,7 @@ class Tox:
|
|||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_int, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_int, c_void_p)
|
||||||
self.friend_status_cb = c_callback(callback)
|
self.friend_status_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_status(self._tox_pointer, self.friend_status_cb, c_void_p(user_data))
|
Tox.libtoxcore.tox_callback_friend_status(self._tox_pointer, self.friend_status_cb)
|
||||||
|
|
||||||
def friend_get_connection_status(self, friend_number):
|
def friend_get_connection_status(self, friend_number):
|
||||||
"""
|
"""
|
||||||
@ -863,7 +866,7 @@ class Tox:
|
|||||||
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
||||||
raise ArgumentError('The friend_number did not designate a valid friend.')
|
raise ArgumentError('The friend_number did not designate a valid friend.')
|
||||||
|
|
||||||
def callback_friend_connection_status(self, callback, user_data):
|
def callback_friend_connection_status(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_connection_status` event. Pass NULL to unset.
|
Set the callback for the `friend_connection_status` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -876,12 +879,11 @@ class Tox:
|
|||||||
The friend number (c_uint32) of the friend whose connection status changed,
|
The friend number (c_uint32) of the friend whose connection status changed,
|
||||||
The result of calling tox_friend_get_connection_status (TOX_CONNECTION) on the passed friend_number,
|
The result of calling tox_friend_get_connection_status (TOX_CONNECTION) on the passed friend_number,
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_int, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_int, c_void_p)
|
||||||
self.friend_connection_status_cb = c_callback(callback)
|
self.friend_connection_status_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_connection_status(self._tox_pointer,
|
Tox.libtoxcore.tox_callback_friend_connection_status(self._tox_pointer,
|
||||||
self.friend_connection_status_cb, c_void_p(user_data))
|
self.friend_connection_status_cb)
|
||||||
|
|
||||||
def friend_get_typing(self, friend_number):
|
def friend_get_typing(self, friend_number):
|
||||||
"""
|
"""
|
||||||
@ -903,7 +905,7 @@ class Tox:
|
|||||||
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
elif tox_err_friend_query == TOX_ERR_FRIEND_QUERY['FRIEND_NOT_FOUND']:
|
||||||
raise ArgumentError('The friend_number did not designate a valid friend.')
|
raise ArgumentError('The friend_number did not designate a valid friend.')
|
||||||
|
|
||||||
def callback_friend_typing(self, callback, user_data):
|
def callback_friend_typing(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_typing` event. Pass NULL to unset.
|
Set the callback for the `friend_typing` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -913,11 +915,10 @@ class Tox:
|
|||||||
The friend number (c_uint32) of the friend who started or stopped typing,
|
The friend number (c_uint32) of the friend who started or stopped typing,
|
||||||
The result of calling tox_friend_get_typing (c_bool) on the passed friend_number,
|
The result of calling tox_friend_get_typing (c_bool) on the passed friend_number,
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_bool, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_bool, c_void_p)
|
||||||
self.friend_typing_cb = c_callback(callback)
|
self.friend_typing_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_typing(self._tox_pointer, self.friend_typing_cb, c_void_p(user_data))
|
Tox.libtoxcore.tox_callback_friend_typing(self._tox_pointer, self.friend_typing_cb)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Sending private messages
|
# Sending private messages
|
||||||
@ -982,7 +983,7 @@ class Tox:
|
|||||||
elif tox_err_friend_send_message == TOX_ERR_FRIEND_SEND_MESSAGE['EMPTY']:
|
elif tox_err_friend_send_message == TOX_ERR_FRIEND_SEND_MESSAGE['EMPTY']:
|
||||||
raise ArgumentError('Attempted to send a zero-length message.')
|
raise ArgumentError('Attempted to send a zero-length message.')
|
||||||
|
|
||||||
def callback_friend_read_receipt(self, callback, user_data):
|
def callback_friend_read_receipt(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_read_receipt` event. Pass None to unset.
|
Set the callback for the `friend_read_receipt` event. Pass None to unset.
|
||||||
|
|
||||||
@ -998,13 +999,13 @@ class Tox:
|
|||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_void_p)
|
||||||
self.friend_read_receipt_cb = c_callback(callback)
|
self.friend_read_receipt_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_read_receipt(self._tox_pointer,
|
Tox.libtoxcore.tox_callback_friend_read_receipt(self._tox_pointer,
|
||||||
self.friend_read_receipt_cb, c_void_p(user_data))
|
self.friend_read_receipt_cb)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Receiving private messages and friend requests
|
# Receiving private messages and friend requests
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def callback_friend_request(self, callback, user_data):
|
def callback_friend_request(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_request` event. Pass None to unset.
|
Set the callback for the `friend_request` event. Pass None to unset.
|
||||||
|
|
||||||
@ -1019,9 +1020,9 @@ class Tox:
|
|||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, POINTER(c_uint8), c_char_p, c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, POINTER(c_uint8), c_char_p, c_size_t, c_void_p)
|
||||||
self.friend_request_cb = c_callback(callback)
|
self.friend_request_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_request(self._tox_pointer, self.friend_request_cb, c_void_p(user_data))
|
Tox.libtoxcore.tox_callback_friend_request(self._tox_pointer, self.friend_request_cb)
|
||||||
|
|
||||||
def callback_friend_message(self, callback, user_data):
|
def callback_friend_message(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_message` event. Pass None to unset.
|
Set the callback for the `friend_message` event. Pass None to unset.
|
||||||
|
|
||||||
@ -1033,11 +1034,10 @@ class Tox:
|
|||||||
The message data (c_char_p) they sent,
|
The message data (c_char_p) they sent,
|
||||||
The size (c_size_t) of the message byte array.
|
The size (c_size_t) of the message byte array.
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_int, c_char_p, c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_int, c_char_p, c_size_t, c_void_p)
|
||||||
self.friend_message_cb = c_callback(callback)
|
self.friend_message_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_friend_message(self._tox_pointer, self.friend_message_cb, c_void_p(user_data))
|
Tox.libtoxcore.tox_callback_friend_message(self._tox_pointer, self.friend_message_cb)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# File transmission: common between sending and receiving
|
# File transmission: common between sending and receiving
|
||||||
@ -1095,7 +1095,7 @@ class Tox:
|
|||||||
elif tox_err_file_control == TOX_ERR_FILE_CONTROL['SENDQ']:
|
elif tox_err_file_control == TOX_ERR_FILE_CONTROL['SENDQ']:
|
||||||
raise RuntimeError('Packet queue is full.')
|
raise RuntimeError('Packet queue is full.')
|
||||||
|
|
||||||
def callback_file_recv_control(self, callback, user_data):
|
def callback_file_recv_control(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `file_recv_control` event. Pass NULL to unset.
|
Set the callback for the `file_recv_control` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -1110,12 +1110,11 @@ class Tox:
|
|||||||
The friend-specific file number (c_uint32) the data received is associated with.
|
The friend-specific file number (c_uint32) the data received is associated with.
|
||||||
The file control (TOX_FILE_CONTROL) command received.
|
The file control (TOX_FILE_CONTROL) command received.
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_int, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_int, c_void_p)
|
||||||
self.file_recv_control_cb = c_callback(callback)
|
self.file_recv_control_cb = c_callback(callback)
|
||||||
Tox.libtoxcore.tox_callback_file_recv_control(self._tox_pointer,
|
Tox.libtoxcore.tox_callback_file_recv_control(self._tox_pointer,
|
||||||
self.file_recv_control_cb, user_data)
|
self.file_recv_control_cb)
|
||||||
|
|
||||||
def file_seek(self, friend_number, file_number, position):
|
def file_seek(self, friend_number, file_number, position):
|
||||||
"""
|
"""
|
||||||
@ -1285,7 +1284,7 @@ class Tox:
|
|||||||
elif tox_err_file_send_chunk == TOX_ERR_FILE_SEND_CHUNK['WRONG_POSITION']:
|
elif tox_err_file_send_chunk == TOX_ERR_FILE_SEND_CHUNK['WRONG_POSITION']:
|
||||||
raise ArgumentError('Position parameter was wrong.')
|
raise ArgumentError('Position parameter was wrong.')
|
||||||
|
|
||||||
def callback_file_chunk_request(self, callback, user_data):
|
def callback_file_chunk_request(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `file_chunk_request` event. Pass None to unset.
|
Set the callback for the `file_chunk_request` event. Pass None to unset.
|
||||||
|
|
||||||
@ -1311,17 +1310,16 @@ class Tox:
|
|||||||
The file or stream position (c_uint64) from which to continue reading.
|
The file or stream position (c_uint64) from which to continue reading.
|
||||||
The number of bytes (c_size_t) requested for the current chunk.
|
The number of bytes (c_size_t) requested for the current chunk.
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint64, c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint64, c_size_t, c_void_p)
|
||||||
self.file_chunk_request_cb = c_callback(callback)
|
self.file_chunk_request_cb = c_callback(callback)
|
||||||
self.libtoxcore.tox_callback_file_chunk_request(self._tox_pointer, self.file_chunk_request_cb, user_data)
|
self.libtoxcore.tox_callback_file_chunk_request(self._tox_pointer, self.file_chunk_request_cb)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# File transmission: receiving
|
# File transmission: receiving
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def callback_file_recv(self, callback, user_data):
|
def callback_file_recv(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `file_recv` event. Pass None to unset.
|
Set the callback for the `file_recv` event. Pass None to unset.
|
||||||
|
|
||||||
@ -1341,13 +1339,12 @@ class Tox:
|
|||||||
send request.
|
send request.
|
||||||
Size in bytes (c_size_t) of the filename.
|
Size in bytes (c_size_t) of the filename.
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint32, c_uint64, c_char_p, c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint32, c_uint64, c_char_p, c_size_t)
|
||||||
self.file_recv_cb = c_callback(callback)
|
self.file_recv_cb = c_callback(callback)
|
||||||
self.libtoxcore.tox_callback_file_recv(self._tox_pointer, self.file_recv_cb, user_data)
|
self.libtoxcore.tox_callback_file_recv(self._tox_pointer, self.file_recv_cb)
|
||||||
|
|
||||||
def callback_file_recv_chunk(self, callback, user_data):
|
def callback_file_recv_chunk(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `file_recv_chunk` event. Pass NULL to unset.
|
Set the callback for the `file_recv_chunk` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -1368,11 +1365,10 @@ class Tox:
|
|||||||
A byte array (c_char_p) containing the received chunk.
|
A byte array (c_char_p) containing the received chunk.
|
||||||
The length (c_size_t) of the received chunk.
|
The length (c_size_t) of the received chunk.
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint64, POINTER(c_uint8), c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint64, POINTER(c_uint8), c_size_t, c_void_p)
|
||||||
self.file_recv_chunk_cb = c_callback(callback)
|
self.file_recv_chunk_cb = c_callback(callback)
|
||||||
self.libtoxcore.tox_callback_file_recv_chunk(self._tox_pointer, self.file_recv_chunk_cb, user_data)
|
self.libtoxcore.tox_callback_file_recv_chunk(self._tox_pointer, self.file_recv_chunk_cb)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Low-level custom packet sending and receiving
|
# Low-level custom packet sending and receiving
|
||||||
@ -1453,7 +1449,7 @@ class Tox:
|
|||||||
elif tox_err_friend_custom_packet == TOX_ERR_FRIEND_CUSTOM_PACKET['SENDQ']:
|
elif tox_err_friend_custom_packet == TOX_ERR_FRIEND_CUSTOM_PACKET['SENDQ']:
|
||||||
raise RuntimeError('Packet queue is full.')
|
raise RuntimeError('Packet queue is full.')
|
||||||
|
|
||||||
def callback_friend_lossy_packet(self, callback, user_data):
|
def callback_friend_lossy_packet(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_lossy_packet` event. Pass NULL to unset.
|
Set the callback for the `friend_lossy_packet` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -1463,13 +1459,12 @@ class Tox:
|
|||||||
A byte array (c_uint8 array) containing the received packet data,
|
A byte array (c_uint8 array) containing the received packet data,
|
||||||
length (c_size_t) - The length of the packet data byte array,
|
length (c_size_t) - The length of the packet data byte array,
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, POINTER(c_uint8), c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, POINTER(c_uint8), c_size_t, c_void_p)
|
||||||
self.friend_lossy_packet_cb = c_callback(callback)
|
self.friend_lossy_packet_cb = c_callback(callback)
|
||||||
self.libtoxcore.tox_callback_friend_lossy_packet(self._tox_pointer, self.friend_lossy_packet_cb, user_data)
|
self.libtoxcore.tox_callback_friend_lossy_packet(self._tox_pointer, self.friend_lossy_packet_cb)
|
||||||
|
|
||||||
def callback_friend_lossless_packet(self, callback, user_data):
|
def callback_friend_lossless_packet(self, callback):
|
||||||
"""
|
"""
|
||||||
Set the callback for the `friend_lossless_packet` event. Pass NULL to unset.
|
Set the callback for the `friend_lossless_packet` event. Pass NULL to unset.
|
||||||
|
|
||||||
@ -1479,12 +1474,10 @@ class Tox:
|
|||||||
A byte array (c_uint8 array) containing the received packet data,
|
A byte array (c_uint8 array) containing the received packet data,
|
||||||
length (c_size_t) - The length of the packet data byte array,
|
length (c_size_t) - The length of the packet data byte array,
|
||||||
pointer (c_void_p) to user_data
|
pointer (c_void_p) to user_data
|
||||||
:param user_data: pointer (c_void_p) to user data
|
|
||||||
"""
|
"""
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, POINTER(c_uint8), c_size_t, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_uint32, POINTER(c_uint8), c_size_t, c_void_p)
|
||||||
self.friend_lossless_packet_cb = c_callback(callback)
|
self.friend_lossless_packet_cb = c_callback(callback)
|
||||||
self.libtoxcore.tox_callback_friend_lossless_packet(self._tox_pointer, self.friend_lossless_packet_cb,
|
self.libtoxcore.tox_callback_friend_lossless_packet(self._tox_pointer, self.friend_lossless_packet_cb)
|
||||||
user_data)
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Low-level network information
|
# Low-level network information
|
||||||
|
Loading…
Reference in New Issue
Block a user