invite fix

This commit is contained in:
ingvar1995 2016-07-15 12:12:06 +03:00
parent 4abd72e278
commit 2745caa531
4 changed files with 17 additions and 11 deletions

View file

@ -314,7 +314,7 @@ def group_message(window, tray, tox):
def group_invite(tox, friend_number, invite_data, length, user_data): def group_invite(tox, friend_number, invite_data, length, user_data):
invoke_in_main_thread(Profile.get_instance().process_group_invite, invoke_in_main_thread(Profile.get_instance().process_group_invite,
friend_number, friend_number,
invite_data[:length]) bytes(invite_data[:length]))
def group_self_join(tox, group_number, user_data): def group_self_join(tox, group_number, user_data):

View file

@ -12,9 +12,10 @@ class GroupChat(contact.Contact):
def set_status(self, value): def set_status(self, value):
print('In gc set_status') 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._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): def add_peer(self, peer_id):
print(peer_id) print(peer_id)

View file

@ -1262,9 +1262,12 @@ class Profile(basecontact.BaseContact, Singleton):
return list(filter(lambda x: type(x) is GroupChat, self._friends_and_gc)) return list(filter(lambda x: type(x) is GroupChat, self._friends_and_gc))
def add_gc(self, num): def add_gc(self, num):
tox_id = self._tox.group_get_chat_id(num) try:
name = self._tox.group_get_name(num) tox_id = self._tox.group_get_chat_id(num)
topic = self._tox.group_get_topic(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() item = self.create_friend_item()
try: try:
if not self._history.friend_exists_in_db(tox_id): if not self._history.friend_exists_in_db(tox_id):
@ -1289,6 +1292,7 @@ class Profile(basecontact.BaseContact, Singleton):
if password: if password:
self._tox.group_founder_set_password(num, bytes(password, 'utf-8')) self._tox.group_founder_set_password(num, bytes(password, 'utf-8'))
self.add_gc(num) self.add_gc(num)
self.get_gc_by_number(num).set_status(TOX_USER_STATUS['NONE'])
def process_group_invite(self, friend_num, data): def process_group_invite(self, friend_num, data):
# TODO: support password # TODO: support password
@ -1302,6 +1306,7 @@ class Profile(basecontact.BaseContact, Singleton):
num = self._tox.group_invite_accept(data) num = self._tox.group_invite_accept(data)
data = self._tox.get_savedata() data = self._tox.get_savedata()
ProfileHelper.get_instance().save_profile(data) ProfileHelper.get_instance().save_profile(data)
print('In gc invite', num)
self.add_gc(num) self.add_gc(num)
elif reply != QtGui.QMessageBox.No: elif reply != QtGui.QMessageBox.No:
if friend_num in self._gc_invites: if friend_num in self._gc_invites:

View file

@ -1549,9 +1549,7 @@ class Tox:
""" """
error = c_int() error = c_int()
func = Tox.libtoxcore.tox_group_new result = Tox.libtoxcore.tox_group_new(self._tox_pointer, privacy_state, group_name,
func.restype = c_uint32
result = func(self._tox_pointer, privacy_state, group_name,
len(group_name), byref(error)) len(group_name), byref(error))
return result return result
@ -1611,7 +1609,8 @@ class Tox:
f.restype = c_bool f.restype = c_bool
result = f(self._tox_pointer, groupnumber, message, result = f(self._tox_pointer, groupnumber, message,
len(message) if message is not None else 0, byref(error)) 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) # Group user-visible client information (nickname/status/role/public key)
@ -2171,6 +2170,7 @@ class Tox:
f.restype = c_uint32 f.restype = c_uint32
result = f(self._tox_pointer, invite_data, len(invite_data), password, result = f(self._tox_pointer, invite_data, len(invite_data), password,
len(password) if password is not None else 0, byref(error)) len(password) if password is not None else 0, byref(error))
print('Invite accept. Result:', result, 'Error:', error.value)
return result return result
def callback_group_invite(self, callback, user_data): def callback_group_invite(self, callback, user_data):
@ -2188,7 +2188,7 @@ class Tox:
user_data - user data 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) self.group_invite_cb = c_callback(callback)
Tox.libtoxcore.tox_callback_group_invite(self._tox_pointer, self.group_invite_cb, user_data) Tox.libtoxcore.tox_callback_group_invite(self._tox_pointer, self.group_invite_cb, user_data)