Philipp Hörist pushed to branch master at gajim / gajim

Commits:

5 changed files:

Changes:

  • gajim/common/app.py
    ... ... @@ -28,7 +28,6 @@
    28 28
     
    
    29 29
     import typing
    
    30 30
     from typing import Any
    
    31
    -from typing import NamedTuple
    
    32 31
     from typing import Optional
    
    33 32
     from typing import cast
    
    34 33
     
    
    ... ... @@ -40,7 +39,6 @@
    40 39
     import pprint
    
    41 40
     from collections import defaultdict
    
    42 41
     
    
    43
    -import nbxmpp
    
    44 42
     from nbxmpp.idlequeue import IdleQueue
    
    45 43
     from gi.repository import Gdk
    
    46 44
     from gi.repository import GLib
    
    ... ... @@ -100,11 +98,6 @@ def __init__(self):
    100 98
     
    
    101 99
     transport_type: dict[str, str] = {}
    
    102 100
     
    
    103
    -# dict of rooms that must be automatically configured
    
    104
    -# and for which we have a list of invities
    
    105
    -# {account: {room_jid: {'invities': []}}}
    
    106
    -automatic_rooms: dict[str, dict[str, dict[str, list[str]]]] = {}
    
    107
    -
    
    108 101
     # list of contacts that has just signed out
    
    109 102
     to_be_removed: dict[str, list[str]] = {}
    
    110 103
     
    
    ... ... @@ -148,12 +141,6 @@ def __init__(self):
    148 141
     _tasks: dict[int, list[Any]] = defaultdict(list)
    
    149 142
     
    
    150 143
     
    
    151
    -class RecentGroupchat(NamedTuple):
    
    152
    -    room: str
    
    153
    -    server: str
    
    154
    -    nickname: str
    
    155
    -
    
    156
    -
    
    157 144
     def print_version() -> None:
    
    158 145
         log('gajim').info('Gajim Version: %s', gajim.__version__)
    
    159 146
     
    
    ... ... @@ -433,10 +420,6 @@ def account_is_available(account: str) -> bool:
    433 420
         return connections[account].state.is_available
    
    434 421
     
    
    435 422
     
    
    436
    -def account_is_disconnected(account: str) -> bool:
    
    437
    -    return not account_is_connected(account)
    
    438
    -
    
    439
    -
    
    440 423
     def get_transport_name_from_jid(
    
    441 424
             jid: str,
    
    442 425
             use_config_setting: bool = True) -> Optional[str]:
    
    ... ... @@ -492,12 +475,6 @@ def get_jid_from_account(account_name: str) -> str:
    492 475
         return jid
    
    493 476
     
    
    494 477
     
    
    495
    -def get_account_from_jid(jid: str) -> Optional[str]:
    
    496
    -    for account in settings.get_accounts():
    
    497
    -        if jid == get_jid_from_account(account):
    
    498
    -            return account
    
    499
    -
    
    500
    -
    
    501 478
     def get_hostname_from_account(account_name: str, use_srv: bool = False) -> str:
    
    502 479
         '''
    
    503 480
         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:
    509 486
         return settings.get_account_setting(account_name, 'hostname')
    
    510 487
     
    
    511 488
     
    
    512
    -def get_notification_image_prefix(jid: str) -> str:
    
    513
    -    '''
    
    514
    -    Returns the prefix for the notification images
    
    515
    -    '''
    
    516
    -    transport_name = get_transport_name_from_jid(jid)
    
    517
    -    if transport_name in ['icq', 'facebook']:
    
    518
    -        prefix = transport_name
    
    519
    -    else:
    
    520
    -        prefix = 'jabber'
    
    521
    -    return prefix
    
    522
    -
    
    523
    -
    
    524
    -def get_recent_groupchats(account: str) -> list[RecentGroupchat]:
    
    525
    -    recent_groupchats = settings.get_account_setting(
    
    526
    -        account, 'recent_groupchats').split()
    
    527
    -
    
    528
    -    recent_list: list[RecentGroupchat] = []
    
    529
    -    for groupchat in recent_groupchats:
    
    530
    -        jid = nbxmpp.JID.from_string(groupchat)
    
    531
    -        recent = RecentGroupchat(jid.localpart, jid.domain, jid.resource)
    
    532
    -        recent_list.append(recent)
    
    533
    -    return recent_list
    
    534
    -
    
    535
    -
    
    536
    -def add_recent_groupchat(account: str, room_jid: str, nickname: str) -> None:
    
    537
    -    recent = settings.get_account_setting(
    
    538
    -        account, 'recent_groupchats').split()
    
    539
    -    full_jid = room_jid + '/' + nickname
    
    540
    -    if full_jid in recent:
    
    541
    -        recent.remove(full_jid)
    
    542
    -    recent.insert(0, full_jid)
    
    543
    -    if len(recent) > 10:
    
    544
    -        recent = recent[0:9]
    
    545
    -    config_value = ' '.join(recent)
    
    546
    -    settings.set_account_setting(account, 'recent_groupchats', config_value)
    
    547
    -
    
    548
    -
    
    549 489
     def get_priority(account: str, show: str) -> int:
    
    550 490
         '''
    
    551 491
         Return the priority an account must have
    
    ... ... @@ -572,14 +512,6 @@ def log(domain: str) -> logging.Logger:
    572 512
         return logging.getLogger(domain)
    
    573 513
     
    
    574 514
     
    
    575
    -def prefers_app_menu() -> bool:
    
    576
    -    if sys.platform == 'darwin':
    
    577
    -        return True
    
    578
    -    if sys.platform == 'win32':
    
    579
    -        return False
    
    580
    -    return app.prefers_app_menu()
    
    581
    -
    
    582
    -
    
    583 515
     def load_css_config() -> None:
    
    584 516
         global css_config   # pylint: disable=global-statement
    
    585 517
         from gajim.gui.css_config import CSSConfig
    

  • gajim/common/application.py
    ... ... @@ -117,6 +117,9 @@ def _init_core(self) -> None:
    117 117
     
    
    118 118
             for account in app.settings.get_active_accounts():
    
    119 119
                 app.connections[account] = Client(account)
    
    120
    +            app.to_be_removed[account] = []
    
    121
    +            app.nicks[account] = app.settings.get_account_setting(account,
    
    122
    +                                                                  'name')
    
    120 123
     
    
    121 124
             app.plugin_manager = PluginManager()
    
    122 125
             app.plugin_manager.init_plugins()
    
    ... ... @@ -378,7 +381,6 @@ def enable_account(self, account: str) -> None:
    378 381
             app.plugin_manager.register_modules_for_account(
    
    379 382
                 app.connections[account])
    
    380 383
     
    
    381
    -        app.automatic_rooms[account] = {}
    
    382 384
             app.to_be_removed[account] = []
    
    383 385
             app.nicks[account] = app.settings.get_account_setting(account, 'name')
    
    384 386
             app.settings.set_account_setting(account, 'active', True)
    
    ... ... @@ -399,7 +401,6 @@ def disable_account(self, account: str) -> None:
    399 401
             if account in app.interface.instances:
    
    400 402
                 del app.interface.instances[account]
    
    401 403
             del app.nicks[account]
    
    402
    -        del app.automatic_rooms[account]
    
    403 404
             del app.to_be_removed[account]
    
    404 405
     
    
    405 406
         def remove_account(self, account: str) -> None:
    

  • gajim/common/modules/muc.py
    ... ... @@ -424,20 +424,6 @@ def _on_config_result(self, task: Task) -> None:
    424 424
             self._con.get_module('Discovery').disco_muc(
    
    425 425
                 result.jid, callback=self._on_disco_result_after_config)
    
    426 426
     
    
    427
    -        # If this is an automatic room creation
    
    428
    -        try:
    
    429
    -            invites = app.automatic_rooms[self._account][result.jid]['invities']
    
    430
    -        except KeyError:
    
    431
    -            return
    
    432
    -
    
    433
    -        user_list = {}
    
    434
    -        for jid in invites:
    
    435
    -            user_list[jid] = {'affiliation': 'member'}
    
    436
    -        self.set_affiliation(result.jid, user_list)
    
    437
    -
    
    438
    -        for jid in invites:
    
    439
    -            self.invite(result.jid, JID.from_string(jid))
    
    440
    -
    
    441 427
         def _on_disco_result_after_config(self, task: Task) -> None:
    
    442 428
             try:
    
    443 429
                 result = task.finish()
    

  • gajim/common/setting_values.py
    ... ... @@ -334,7 +334,6 @@ class _ACCOUNT_DEFAULT:
    334 334
         'name',
    
    335 335
         'password',
    
    336 336
         'proxy',
    
    337
    -    'recent_groupchats',
    
    338 337
         'resource',
    
    339 338
         'roster_version',
    
    340 339
         'send_chatstate_default',
    
    ... ... @@ -450,7 +449,6 @@ class _ACCOUNT_DEFAULT:
    450 449
             'proxy': '',
    
    451 450
             'publish_location': False,
    
    452 451
             'publish_tune': False,
    
    453
    -        'recent_groupchats': '',
    
    454 452
             'request_user_data': True,
    
    455 453
             'resource': 'gajim.$rand',
    
    456 454
             'restore_last_status': False,
    

  • gajim/gui_interface.py
    ... ... @@ -97,11 +97,6 @@ def __init__(self):
    97 97
     
    
    98 98
             self.instances: dict[str, Any] = {}
    
    99 99
     
    
    100
    -        for acc in app.settings.get_active_accounts():
    
    101
    -            app.automatic_rooms[acc] = {}
    
    102
    -            app.to_be_removed[acc] = []
    
    103
    -            app.nicks[acc] = app.settings.get_account_setting(acc, 'name')
    
    104
    -
    
    105 100
         # Jingle File Transfer
    
    106 101
         @staticmethod
    
    107 102
         def handle_event_file_error(title: str, message: str) -> None: