refactoring and is_muted fix
This commit is contained in:
parent
ce19efe340
commit
0f9aa4f515
@ -20,11 +20,7 @@ class Node:
|
||||
priority = property(get_priority)
|
||||
|
||||
def get_data(self):
|
||||
return bytes(self._ip, 'utf-8'), self._port, self._tox_key
|
||||
|
||||
|
||||
def _get_nodes_path():
|
||||
return join_path(curr_directory(__file__), 'nodes.json')
|
||||
return self._ip, self._port, self._tox_key
|
||||
|
||||
|
||||
def generate_nodes(nodes_count=DEFAULT_NODES_COUNT):
|
||||
@ -39,14 +35,6 @@ def generate_nodes(nodes_count=DEFAULT_NODES_COUNT):
|
||||
yield node.get_data()
|
||||
|
||||
|
||||
def save_nodes(nodes):
|
||||
if not nodes:
|
||||
return
|
||||
print('Saving nodes...')
|
||||
with open(_get_nodes_path(), 'wb') as fl:
|
||||
fl.write(nodes)
|
||||
|
||||
|
||||
def download_nodes_list(settings):
|
||||
url = 'https://nodes.tox.chat/json'
|
||||
if not settings['download_nodes_list']:
|
||||
@ -58,7 +46,7 @@ def download_nodes_list(settings):
|
||||
req.add_header('Content-Type', 'application/json')
|
||||
response = urllib.request.urlopen(req)
|
||||
result = response.read()
|
||||
save_nodes(result)
|
||||
_save_nodes(result)
|
||||
except Exception as ex:
|
||||
log('TOX nodes loading error: ' + str(ex))
|
||||
else: # proxy
|
||||
@ -78,6 +66,18 @@ def download_nodes_list(settings):
|
||||
QtCore.QThread.msleep(1)
|
||||
QtCore.QCoreApplication.processEvents()
|
||||
data = bytes(reply.readAll().data())
|
||||
save_nodes(data)
|
||||
_save_nodes(data)
|
||||
except Exception as ex:
|
||||
log('TOX nodes loading error: ' + str(ex))
|
||||
|
||||
|
||||
def _get_nodes_path():
|
||||
return join_path(curr_directory(__file__), 'nodes.json')
|
||||
|
||||
|
||||
def _save_nodes(nodes):
|
||||
if not nodes:
|
||||
return
|
||||
print('Saving nodes...')
|
||||
with open(_get_nodes_path(), 'wb') as fl:
|
||||
fl.write(nodes)
|
||||
|
@ -39,7 +39,8 @@ class BaseContact:
|
||||
return self._name
|
||||
|
||||
def set_name(self, value):
|
||||
if self._name != value:
|
||||
if self._name == value:
|
||||
return
|
||||
self._name = value
|
||||
self._widget.name.setText(self._name)
|
||||
self._widget.name.repaint()
|
||||
@ -60,7 +61,8 @@ class BaseContact:
|
||||
return self._status_message
|
||||
|
||||
def set_status_message(self, value):
|
||||
if self._status_message != value:
|
||||
if self._status_message == value:
|
||||
return
|
||||
self._status_message = value
|
||||
self._widget.status_message.setText(self._status_message)
|
||||
self._widget.status_message.repaint()
|
||||
@ -81,7 +83,8 @@ class BaseContact:
|
||||
return self._status
|
||||
|
||||
def set_status(self, value):
|
||||
if self._status != value:
|
||||
if self._status == value:
|
||||
return
|
||||
self._status = value
|
||||
self._widget.connection_status.update(value)
|
||||
self._status_changed_event(self._status)
|
||||
|
@ -2,6 +2,10 @@ from pydenticon import Generator
|
||||
import hashlib
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Typing notifications
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class BaseTypingNotificationHandler:
|
||||
|
||||
DEFAULT_HANDLER = None
|
||||
@ -26,6 +30,11 @@ class FriendTypingNotificationHandler(BaseTypingNotificationHandler):
|
||||
BaseTypingNotificationHandler.DEFAULT_HANDLER = BaseTypingNotificationHandler()
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Identicons support
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def generate_avatar(public_key):
|
||||
foreground = ['rgb(45,79,255)', 'rgb(185, 66, 244)', 'rgb(185, 66, 244)',
|
||||
'rgb(254,180,44)', 'rgb(252, 2, 2)', 'rgb(109, 198, 0)',
|
||||
|
@ -1,6 +1,9 @@
|
||||
|
||||
|
||||
class GroupChatPeer:
|
||||
"""
|
||||
Represents peer in group chat.
|
||||
"""
|
||||
|
||||
def __init__(self, peer_id, name, status, role, public_key, is_current_user=False, is_muted=False):
|
||||
self._peer_id = peer_id
|
||||
@ -11,11 +14,29 @@ class GroupChatPeer:
|
||||
self._is_current_user = is_current_user
|
||||
self._is_muted = is_muted
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Readonly properties
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
def get_id(self):
|
||||
return self._peer_id
|
||||
|
||||
id = property(get_id)
|
||||
|
||||
def get_public_key(self):
|
||||
return self._public_key
|
||||
|
||||
public_key = property(get_public_key)
|
||||
|
||||
def get_is_current_user(self):
|
||||
return self._is_current_user
|
||||
|
||||
is_current_user = property(get_is_current_user)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Read-write properties
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
def get_name(self):
|
||||
return self._name
|
||||
|
||||
@ -40,17 +61,10 @@ class GroupChatPeer:
|
||||
|
||||
role = property(get_role, set_role)
|
||||
|
||||
def get_public_key(self):
|
||||
return self._public_key
|
||||
|
||||
public_key = property(get_public_key)
|
||||
|
||||
def get_is_current_user(self):
|
||||
return self._is_current_user
|
||||
|
||||
is_current_user = property(get_is_current_user)
|
||||
|
||||
def get_is_muted(self):
|
||||
return self._is_muted
|
||||
|
||||
is_muted = property(get_is_muted)
|
||||
def set_is_muted(self, is_muted):
|
||||
self._is_muted = is_muted
|
||||
|
||||
is_muted = property(get_is_muted, set_is_muted)
|
||||
|
@ -218,6 +218,7 @@ class Tox:
|
||||
:param public_key: The long term public key of the bootstrap node (TOX_PUBLIC_KEY_SIZE bytes).
|
||||
:return: True on success.
|
||||
"""
|
||||
address = bytes(address, 'utf-8')
|
||||
tox_err_bootstrap = c_int()
|
||||
result = Tox.libtoxcore.tox_bootstrap(self._tox_pointer, c_char_p(address), c_uint16(port),
|
||||
string_to_bin(public_key), byref(tox_err_bootstrap))
|
||||
@ -244,6 +245,7 @@ class Tox:
|
||||
:param public_key: The long term public key of the TCP relay (TOX_PUBLIC_KEY_SIZE bytes).
|
||||
:return: True on success.
|
||||
"""
|
||||
address = bytes(address, 'utf-8')
|
||||
tox_err_bootstrap = c_int()
|
||||
result = Tox.libtoxcore.tox_add_tcp_relay(self._tox_pointer, c_char_p(address), c_uint16(port),
|
||||
string_to_bin(public_key), byref(tox_err_bootstrap))
|
||||
|
Loading…
Reference in New Issue
Block a user