invite fix
This commit is contained in:
parent
4abd72e278
commit
2745caa531
@ -314,7 +314,7 @@ def group_message(window, tray, tox):
|
||||
def group_invite(tox, friend_number, invite_data, length, user_data):
|
||||
invoke_in_main_thread(Profile.get_instance().process_group_invite,
|
||||
friend_number,
|
||||
invite_data[:length])
|
||||
bytes(invite_data[:length]))
|
||||
|
||||
|
||||
def group_self_join(tox, group_number, user_data):
|
||||
|
@ -12,9 +12,10 @@ class GroupChat(contact.Contact):
|
||||
|
||||
def set_status(self, value):
|
||||
print('In gc set_status')
|
||||
self.name = self._tox.group_get_name(self._number)
|
||||
super().set_status(value)
|
||||
self.name = bytes(self._tox.group_get_name(self._number), 'utf-8')
|
||||
self._tox_id = self._tox.group_get_chat_id(self._number)
|
||||
self.status_message = self._tox.group_get_topic(self._number)
|
||||
self.status_message = bytes(self._tox.group_get_topic(self._number), 'utf-8')
|
||||
|
||||
def add_peer(self, peer_id):
|
||||
print(peer_id)
|
||||
|
@ -1262,9 +1262,12 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||
return list(filter(lambda x: type(x) is GroupChat, self._friends_and_gc))
|
||||
|
||||
def add_gc(self, num):
|
||||
tox_id = self._tox.group_get_chat_id(num)
|
||||
name = self._tox.group_get_name(num)
|
||||
topic = self._tox.group_get_topic(num)
|
||||
try:
|
||||
tox_id = self._tox.group_get_chat_id(num)
|
||||
name = self._tox.group_get_name(num)
|
||||
topic = self._tox.group_get_topic(num)
|
||||
except:
|
||||
tox_id = name = topic = ''
|
||||
item = self.create_friend_item()
|
||||
try:
|
||||
if not self._history.friend_exists_in_db(tox_id):
|
||||
@ -1289,6 +1292,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||
if password:
|
||||
self._tox.group_founder_set_password(num, bytes(password, 'utf-8'))
|
||||
self.add_gc(num)
|
||||
self.get_gc_by_number(num).set_status(TOX_USER_STATUS['NONE'])
|
||||
|
||||
def process_group_invite(self, friend_num, data):
|
||||
# TODO: support password
|
||||
@ -1302,6 +1306,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||
num = self._tox.group_invite_accept(data)
|
||||
data = self._tox.get_savedata()
|
||||
ProfileHelper.get_instance().save_profile(data)
|
||||
print('In gc invite', num)
|
||||
self.add_gc(num)
|
||||
elif reply != QtGui.QMessageBox.No:
|
||||
if friend_num in self._gc_invites:
|
||||
|
@ -1549,9 +1549,7 @@ class Tox:
|
||||
"""
|
||||
|
||||
error = c_int()
|
||||
func = Tox.libtoxcore.tox_group_new
|
||||
func.restype = c_uint32
|
||||
result = func(self._tox_pointer, privacy_state, group_name,
|
||||
result = Tox.libtoxcore.tox_group_new(self._tox_pointer, privacy_state, group_name,
|
||||
len(group_name), byref(error))
|
||||
return result
|
||||
|
||||
@ -1611,7 +1609,8 @@ class Tox:
|
||||
f.restype = c_bool
|
||||
result = f(self._tox_pointer, groupnumber, message,
|
||||
len(message) if message is not None else 0, byref(error))
|
||||
return result.value
|
||||
print('In group leave. Result:', result, 'Error:', error.value)
|
||||
return result
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Group user-visible client information (nickname/status/role/public key)
|
||||
@ -2171,6 +2170,7 @@ class Tox:
|
||||
f.restype = c_uint32
|
||||
result = f(self._tox_pointer, invite_data, len(invite_data), password,
|
||||
len(password) if password is not None else 0, byref(error))
|
||||
print('Invite accept. Result:', result, 'Error:', error.value)
|
||||
return result
|
||||
|
||||
def callback_group_invite(self, callback, user_data):
|
||||
@ -2188,7 +2188,7 @@ class Tox:
|
||||
user_data - 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, POINTER(c_uint8), c_size_t, c_void_p)
|
||||
self.group_invite_cb = c_callback(callback)
|
||||
Tox.libtoxcore.tox_callback_group_invite(self._tox_pointer, self.group_invite_cb, user_data)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user