Philipp Hörist pushed to branch master at gajim / gajim
Commits: 1d1a7c99 by Philipp Hörist at 2022-10-29T14:36:01+02:00 refactor: Remove unused code
- - - - - 1095fb32 by Philipp Hörist at 2022-10-29T14:40:06+02:00 refactor: Move init code into application
- - - - - f275c18e by Philipp Hörist at 2022-10-29T14:46:11+02:00 refactor: Remove unused code
- - - - -
5 changed files:
- gajim/common/app.py - gajim/common/application.py - gajim/common/modules/muc.py - gajim/common/setting_values.py - gajim/gui_interface.py
Changes:
===================================== gajim/common/app.py ===================================== @@ -28,7 +28,6 @@
import typing from typing import Any -from typing import NamedTuple from typing import Optional from typing import cast
@@ -40,7 +39,6 @@ import pprint from collections import defaultdict
-import nbxmpp from nbxmpp.idlequeue import IdleQueue from gi.repository import Gdk from gi.repository import GLib @@ -100,11 +98,6 @@ def __init__(self):
transport_type: dict[str, str] = {}
-# dict of rooms that must be automatically configured -# and for which we have a list of invities -# {account: {room_jid: {'invities': []}}} -automatic_rooms: dict[str, dict[str, dict[str, list[str]]]] = {} - # list of contacts that has just signed out to_be_removed: dict[str, list[str]] = {}
@@ -148,12 +141,6 @@ def __init__(self): _tasks: dict[int, list[Any]] = defaultdict(list)
-class RecentGroupchat(NamedTuple): - room: str - server: str - nickname: str - - def print_version() -> None: log('gajim').info('Gajim Version: %s', gajim.__version__)
@@ -433,10 +420,6 @@ def account_is_available(account: str) -> bool: return connections[account].state.is_available
-def account_is_disconnected(account: str) -> bool: - return not account_is_connected(account) - - def get_transport_name_from_jid( jid: str, use_config_setting: bool = True) -> Optional[str]: @@ -492,12 +475,6 @@ def get_jid_from_account(account_name: str) -> str: return jid
-def get_account_from_jid(jid: str) -> Optional[str]: - for account in settings.get_accounts(): - if jid == get_jid_from_account(account): - return account - - def get_hostname_from_account(account_name: str, use_srv: bool = False) -> str: ''' Returns hostname (if custom hostname is used, that is returned) @@ -509,43 +486,6 @@ def get_hostname_from_account(account_name: str, use_srv: bool = False) -> str: return settings.get_account_setting(account_name, 'hostname')
-def get_notification_image_prefix(jid: str) -> str: - ''' - Returns the prefix for the notification images - ''' - transport_name = get_transport_name_from_jid(jid) - if transport_name in ['icq', 'facebook']: - prefix = transport_name - else: - prefix = 'jabber' - return prefix - - -def get_recent_groupchats(account: str) -> list[RecentGroupchat]: - recent_groupchats = settings.get_account_setting( - account, 'recent_groupchats').split() - - recent_list: list[RecentGroupchat] = [] - for groupchat in recent_groupchats: - jid = nbxmpp.JID.from_string(groupchat) - recent = RecentGroupchat(jid.localpart, jid.domain, jid.resource) - recent_list.append(recent) - return recent_list - - -def add_recent_groupchat(account: str, room_jid: str, nickname: str) -> None: - recent = settings.get_account_setting( - account, 'recent_groupchats').split() - full_jid = room_jid + '/' + nickname - if full_jid in recent: - recent.remove(full_jid) - recent.insert(0, full_jid) - if len(recent) > 10: - recent = recent[0:9] - config_value = ' '.join(recent) - settings.set_account_setting(account, 'recent_groupchats', config_value) - - def get_priority(account: str, show: str) -> int: ''' Return the priority an account must have @@ -572,14 +512,6 @@ def log(domain: str) -> logging.Logger: return logging.getLogger(domain)
-def prefers_app_menu() -> bool: - if sys.platform == 'darwin': - return True - if sys.platform == 'win32': - return False - return app.prefers_app_menu() - - def load_css_config() -> None: global css_config # pylint: disable=global-statement from gajim.gui.css_config import CSSConfig
===================================== gajim/common/application.py ===================================== @@ -117,6 +117,9 @@ def _init_core(self) -> None:
for account in app.settings.get_active_accounts(): app.connections[account] = Client(account) + app.to_be_removed[account] = [] + app.nicks[account] = app.settings.get_account_setting(account, + 'name')
app.plugin_manager = PluginManager() app.plugin_manager.init_plugins() @@ -378,7 +381,6 @@ def enable_account(self, account: str) -> None: app.plugin_manager.register_modules_for_account( app.connections[account])
- app.automatic_rooms[account] = {} app.to_be_removed[account] = [] app.nicks[account] = app.settings.get_account_setting(account, 'name') app.settings.set_account_setting(account, 'active', True) @@ -399,7 +401,6 @@ def disable_account(self, account: str) -> None: if account in app.interface.instances: del app.interface.instances[account] del app.nicks[account] - del app.automatic_rooms[account] del app.to_be_removed[account]
def remove_account(self, account: str) -> None:
===================================== gajim/common/modules/muc.py ===================================== @@ -424,20 +424,6 @@ def _on_config_result(self, task: Task) -> None: self._con.get_module('Discovery').disco_muc( result.jid, callback=self._on_disco_result_after_config)
- # If this is an automatic room creation - try: - invites = app.automatic_rooms[self._account][result.jid]['invities'] - except KeyError: - return - - user_list = {} - for jid in invites: - user_list[jid] = {'affiliation': 'member'} - self.set_affiliation(result.jid, user_list) - - for jid in invites: - self.invite(result.jid, JID.from_string(jid)) - def _on_disco_result_after_config(self, task: Task) -> None: try: result = task.finish()
===================================== gajim/common/setting_values.py ===================================== @@ -334,7 +334,6 @@ class _ACCOUNT_DEFAULT: 'name', 'password', 'proxy', - 'recent_groupchats', 'resource', 'roster_version', 'send_chatstate_default', @@ -450,7 +449,6 @@ class _ACCOUNT_DEFAULT: 'proxy': '', 'publish_location': False, 'publish_tune': False, - 'recent_groupchats': '', 'request_user_data': True, 'resource': 'gajim.$rand', 'restore_last_status': False,
===================================== gajim/gui_interface.py ===================================== @@ -97,11 +97,6 @@ def __init__(self):
self.instances: dict[str, Any] = {}
- for acc in app.settings.get_active_accounts(): - app.automatic_rooms[acc] = {} - app.to_be_removed[acc] = [] - app.nicks[acc] = app.settings.get_account_setting(acc, 'name') - # Jingle File Transfer @staticmethod def handle_event_file_error(title: str, message: str) -> None:
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/57cb288802be7969ae00d73e16ba911d...