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

Commits:

4 changed files:

Changes:

  • gajim/common/client.py
    ... ... @@ -52,7 +52,8 @@ class Client(ConnectionHandlers):
    52 52
             self._client = None
    
    53 53
             self._account = account
    
    54 54
             self.name = account
    
    55
    -        self._hostname = app.config.get_per('accounts', self._account, 'hostname')
    
    55
    +        self._hostname = app.config.get_per(
    
    56
    +            'accounts', self._account, 'hostname')
    
    56 57
             self._user = app.config.get_per('accounts', self._account, 'name')
    
    57 58
             self.password = None
    
    58 59
     
    
    ... ... @@ -135,7 +136,8 @@ class Client(ConnectionHandlers):
    135 136
     
    
    136 137
             self._client.set_ignored_tls_errors(self._get_ignored_ssl_errors())
    
    137 138
     
    
    138
    -        if app.config.get_per('accounts', self._account, 'use_plain_connection'):
    
    139
    +        if app.config.get_per('accounts', self._account,
    
    140
    +                              'use_plain_connection'):
    
    139 141
                 self._client.set_connection_types([ConnectionType.PLAIN])
    
    140 142
     
    
    141 143
             proxy = get_user_proxy(self._account)
    
    ... ... @@ -270,12 +272,12 @@ class Client(ConnectionHandlers):
    270 272
             self.get_module('Chatstate').enabled = True
    
    271 273
             self.get_module('MAM').reset_state()
    
    272 274
     
    
    273
    -    def _on_stanza_sent(self, _client, signal_name, stanza):
    
    275
    +    def _on_stanza_sent(self, _client, _signal_name, stanza):
    
    274 276
             app.nec.push_incoming_event(NetworkEvent('stanza-sent',
    
    275 277
                                                      account=self._account,
    
    276 278
                                                      stanza=stanza))
    
    277 279
     
    
    278
    -    def _on_stanza_received(self, _client, signal_name, stanza):
    
    280
    +    def _on_stanza_received(self, _client, _signal_name, stanza):
    
    279 281
             app.nec.push_incoming_event(NetworkEvent('stanza-received',
    
    280 282
                                                      account=self._account,
    
    281 283
                                                      stanza=stanza))
    
    ... ... @@ -365,7 +367,7 @@ class Client(ConnectionHandlers):
    365 367
             return modules.get(self._account, name)
    
    366 368
     
    
    367 369
         @helpers.call_counter
    
    368
    -    def connect_machine(self, restart=False):
    
    370
    +    def connect_machine(self):
    
    369 371
             log.info('Connect machine state: %s', self._connect_machine_calls)
    
    370 372
             if self._connect_machine_calls == 1:
    
    371 373
                 self.get_module('MetaContacts').get_metacontacts()
    
    ... ... @@ -506,8 +508,8 @@ class Client(ConnectionHandlers):
    506 508
         def _abort_reconnect(self):
    
    507 509
             self._set_state(ClientState.DISCONNECTED)
    
    508 510
             self._disable_reconnect_timer()
    
    509
    -        app.nec.push_incoming_event(OurShowEvent(
    
    510
    -                None, conn=self, show='offline'))
    
    511
    +        app.nec.push_incoming_event(
    
    512
    +            OurShowEvent(None, conn=self, show='offline'))
    
    511 513
     
    
    512 514
             if self._destroy_client:
    
    513 515
                 self._client.destroy()
    

  • gajim/common/helpers.py
    ... ... @@ -1289,7 +1289,7 @@ def call_counter(func):
    1289 1289
             if restart:
    
    1290 1290
                 self._connect_machine_calls = 0
    
    1291 1291
             self._connect_machine_calls += 1
    
    1292
    -        return func(self, restart=False)
    
    1292
    +        return func(self)
    
    1293 1293
         return helper
    
    1294 1294
     
    
    1295 1295
     def get_sync_threshold(jid, archive_info):
    

  • gajim/plugins/gajimplugin.py
    ... ... @@ -36,7 +36,7 @@ from gajim.common.types import PluginExtensionPoints # pylint: disable=W0611
    36 36
     from gajim.common.types import EventHandlersDict  # pylint: disable=W0611
    
    37 37
     from gajim.common.types import PluginEvents  # pylint: disable=W0611
    
    38 38
     
    
    39
    -from gajim.plugins.helpers import log_calls, log
    
    39
    +from gajim.plugins.helpers import log
    
    40 40
     from gajim.plugins.gui import GajimPluginConfigDialog
    
    41 41
     
    
    42 42
     
    
    ... ... @@ -161,7 +161,6 @@ class GajimPlugin:
    161 161
         subclasses.
    
    162 162
         '''
    
    163 163
     
    
    164
    -    @log_calls('GajimPlugin')
    
    165 164
         def __init__(self) -> None:
    
    166 165
             self.config = GajimPluginConfig(self)
    
    167 166
             '''
    
    ... ... @@ -177,11 +176,9 @@ class GajimPlugin:
    177 176
             self.config_dialog = GajimPluginConfigDialog(self)
    
    178 177
             self.init()
    
    179 178
     
    
    180
    -    @log_calls('GajimPlugin')
    
    181 179
         def save_config(self) -> None:
    
    182 180
             self.config.save()
    
    183 181
     
    
    184
    -    @log_calls('GajimPlugin')
    
    185 182
         def load_config(self) -> None:
    
    186 183
             self.config.load()
    
    187 184
     
    
    ... ... @@ -197,32 +194,26 @@ class GajimPlugin:
    197 194
     
    
    198 195
             return False
    
    199 196
     
    
    200
    -    @log_calls('GajimPlugin')
    
    201 197
         def local_file_path(self, file_name):
    
    202 198
             return os.path.join(self.__path__, file_name)
    
    203 199
     
    
    204
    -    @log_calls('GajimPlugin')
    
    205 200
         def init(self):
    
    206 201
             pass
    
    207 202
     
    
    208
    -    @log_calls('GajimPlugin')
    
    209 203
         def activate(self):
    
    210 204
             pass
    
    211 205
     
    
    212
    -    @log_calls('GajimPlugin')
    
    213 206
         def deactivate(self):
    
    214 207
             pass
    
    215 208
     
    
    216 209
     
    
    217 210
     class GajimPluginConfig():
    
    218
    -    @log_calls('GajimPluginConfig')
    
    219 211
         def __init__(self, plugin):
    
    220 212
             self.plugin = plugin
    
    221 213
             self.FILE_PATH = os.path.join(
    
    222 214
                 configpaths.get('PLUGINS_CONFIG_DIR'), self.plugin.short_name)
    
    223 215
             self.data = {}
    
    224 216
     
    
    225
    -    @log_calls('GajimPluginConfig')
    
    226 217
         def __getitem__(self, key):
    
    227 218
             if not key in self.data:
    
    228 219
                 self.data[key] = self.plugin.config_default_values[key][0]
    
    ... ... @@ -230,17 +221,14 @@ class GajimPluginConfig():
    230 221
     
    
    231 222
             return self.data[key]
    
    232 223
     
    
    233
    -    @log_calls('GajimPluginConfig')
    
    234 224
         def __setitem__(self, key, value):
    
    235 225
             self.data[key] = value
    
    236 226
             self.save()
    
    237 227
     
    
    238
    -    @log_calls('GajimPluginConfig')
    
    239 228
         def __delitem__(self, key):
    
    240 229
             del self.data[key]
    
    241 230
             self.save()
    
    242 231
     
    
    243
    -    @log_calls('GajimPluginConfig')
    
    244 232
         def __contains__(self, key):
    
    245 233
             return key in self.data
    
    246 234
     
    
    ... ... @@ -254,13 +242,11 @@ class GajimPluginConfig():
    254 242
         def items(self):
    
    255 243
             return self.data.items()
    
    256 244
     
    
    257
    -    @log_calls('GajimPluginConfig')
    
    258 245
         def save(self):
    
    259 246
             fd = open(self.FILE_PATH, 'wb')
    
    260 247
             pickle.dump(self.data, fd)
    
    261 248
             fd.close()
    
    262 249
     
    
    263
    -    @log_calls('GajimPluginConfig')
    
    264 250
         def load(self):
    
    265 251
             if os.path.isfile(self.FILE_PATH):
    
    266 252
                 fd = open(self.FILE_PATH, 'rb')
    

  • gajim/plugins/pluginmanager.py
    ... ... @@ -42,7 +42,7 @@ from gajim.common.exceptions import PluginsystemError
    42 42
     from gajim.common.helpers import Singleton
    
    43 43
     from gajim.plugins import plugins_i18n
    
    44 44
     
    
    45
    -from gajim.plugins.helpers import log, log_calls
    
    45
    +from gajim.plugins.helpers import log
    
    46 46
     from gajim.plugins.helpers import GajimPluginActivateException
    
    47 47
     from gajim.plugins.gajimplugin import GajimPlugin, GajimPluginException
    
    48 48
     
    
    ... ... @@ -75,7 +75,6 @@ class PluginManager(metaclass=Singleton):
    75 75
                    'destructors' (classes that register GUI extension points)
    
    76 76
         '''
    
    77 77
     
    
    78
    -    #@log_calls('PluginManager')
    
    79 78
         def __init__(self):
    
    80 79
             self.plugins = []
    
    81 80
             '''
    
    ... ... @@ -115,20 +114,17 @@ class PluginManager(metaclass=Singleton):
    115 114
                 pc = self.scan_dir_for_plugins(path)
    
    116 115
                 self.add_plugins(pc)
    
    117 116
     
    
    118
    -    @log_calls('PluginManager')
    
    119 117
         def _plugin_has_entry_in_global_config(self, plugin):
    
    120 118
             if app.config.get_per('plugins', plugin.short_name) is None:
    
    121 119
                 return False
    
    122 120
             return True
    
    123 121
     
    
    124
    -    @log_calls('PluginManager')
    
    125 122
         def _create_plugin_entry_in_global_config(self, plugin):
    
    126 123
             app.config.add_per('plugins', plugin.short_name)
    
    127 124
     
    
    128 125
         def _remove_plugin_entry_in_global_config(self, plugin):
    
    129 126
             app.config.del_per('plugins', plugin.short_name)
    
    130 127
     
    
    131
    -    @log_calls('PluginManager')
    
    132 128
         def update_plugins(self, replace=True, activate=False, plugin_name=None):
    
    133 129
             '''
    
    134 130
             Move plugins from the downloaded folder to the user plugin folder
    
    ... ... @@ -171,11 +167,9 @@ class PluginManager(metaclass=Singleton):
    171 167
             return updated_plugins
    
    172 168
     
    
    173 169
     
    
    174
    -    @log_calls('PluginManager')
    
    175 170
         def init_plugins(self):
    
    176 171
             self._activate_all_plugins_from_global_config()
    
    177 172
     
    
    178
    -    @log_calls('PluginManager')
    
    179 173
         def add_plugin(self, plugin_class):
    
    180 174
             '''
    
    181 175
             :todo: what about adding plug-ins that are already added? Module reload
    
    ... ... @@ -201,7 +195,6 @@ class PluginManager(metaclass=Singleton):
    201 195
                          plugin.name, plugin.version,
    
    202 196
                          plugin.__module__, plugin.short_name)
    
    203 197
     
    
    204
    -    @log_calls('PluginManager')
    
    205 198
         def remove_plugin(self, plugin):
    
    206 199
             '''
    
    207 200
             removes the plugin from the plugin list and deletes all loaded modules
    
    ... ... @@ -227,19 +220,16 @@ class PluginManager(metaclass=Singleton):
    227 220
             for module_to_remove in modules_to_remove:
    
    228 221
                 del sys.modules[module_to_remove]
    
    229 222
     
    
    230
    -    @log_calls('PluginManager')
    
    231 223
         def add_plugins(self, plugin_classes):
    
    232 224
             for plugin_class in plugin_classes:
    
    233 225
                 self.add_plugin(plugin_class)
    
    234 226
     
    
    235
    -    @log_calls('PluginManager')
    
    236 227
         def get_active_plugin(self, plugin_name):
    
    237 228
             for plugin in self.active_plugins:
    
    238 229
                 if plugin.short_name == plugin_name:
    
    239 230
                     return plugin
    
    240 231
             return None
    
    241 232
     
    
    242
    -    @log_calls('PluginManager')
    
    243 233
         def extension_point(self, gui_extpoint_name, *args):
    
    244 234
             '''
    
    245 235
             Invokes all handlers (from plugins) for a particular extension point, but
    
    ... ... @@ -259,7 +249,6 @@ class PluginManager(metaclass=Singleton):
    259 249
             self._execute_all_handlers_of_gui_extension_point(gui_extpoint_name,
    
    260 250
                 *args)
    
    261 251
     
    
    262
    -    @log_calls('PluginManager')
    
    263 252
         def gui_extension_point(self, gui_extpoint_name, *args):
    
    264 253
             '''
    
    265 254
             Invokes all handlers (from plugins) for particular GUI extension point
    
    ... ... @@ -289,7 +278,6 @@ class PluginManager(metaclass=Singleton):
    289 278
             self._execute_all_handlers_of_gui_extension_point(gui_extpoint_name,
    
    290 279
                 *args)
    
    291 280
     
    
    292
    -    @log_calls('PluginManager')
    
    293 281
         def remove_gui_extension_point(self, gui_extpoint_name, *args):
    
    294 282
             '''
    
    295 283
             Removes GUI extension point from collection held by `PluginManager`.
    
    ... ... @@ -339,7 +327,6 @@ class PluginManager(metaclass=Singleton):
    339 327
                 if disconnect_handler is not None:
    
    340 328
                     disconnect_handler(args[0])
    
    341 329
     
    
    342
    -    @log_calls('PluginManager')
    
    343 330
         def _add_gui_extension_point_call_to_list(self, gui_extpoint_name, *args):
    
    344 331
             '''
    
    345 332
             Adds GUI extension point call to list of calls.
    
    ... ... @@ -365,7 +352,6 @@ class PluginManager(metaclass=Singleton):
    365 352
                 self.gui_extension_points.setdefault(gui_extpoint_name, []).append(
    
    366 353
                     args)
    
    367 354
     
    
    368
    -    @log_calls('PluginManager')
    
    369 355
         def _execute_all_handlers_of_gui_extension_point(self, gui_extpoint_name,
    
    370 356
         *args):
    
    371 357
             if gui_extpoint_name in self.gui_extension_points_handlers:
    
    ... ... @@ -444,7 +430,6 @@ class PluginManager(metaclass=Singleton):
    444 430
                                 handler = handler[:4]
    
    445 431
                             con.connection.unregister_handler(*handler)
    
    446 432
     
    
    447
    -    @log_calls('PluginManager')
    
    448 433
         def activate_plugin(self, plugin):
    
    449 434
             '''
    
    450 435
             :param plugin: plugin to be activated
    
    ... ... @@ -507,7 +492,6 @@ class PluginManager(metaclass=Singleton):
    507 492
             for plugin_object in self.active_plugins:
    
    508 493
                 self.deactivate_plugin(plugin_object)
    
    509 494
     
    
    510
    -    @log_calls('PluginManager')
    
    511 495
         def _add_gui_extension_points_handlers_from_plugin(self, plugin):
    
    512 496
             for gui_extpoint_name, gui_extpoint_handlers in \
    
    513 497
             plugin.gui_extension_points.items():
    
    ... ... @@ -518,7 +502,6 @@ class PluginManager(metaclass=Singleton):
    518 502
             if plugin.encryption_name:
    
    519 503
                 self.encryption_plugins[plugin.encryption_name] = plugin
    
    520 504
     
    
    521
    -    @log_calls('PluginManager')
    
    522 505
         def _handle_all_gui_extension_points_with_plugin(self, plugin):
    
    523 506
             for gui_extpoint_name, gui_extpoint_handlers in \
    
    524 507
             plugin.gui_extension_points.items():
    
    ... ... @@ -534,7 +517,6 @@ class PluginManager(metaclass=Singleton):
    534 517
                                             handler, exc_info=True)
    
    535 518
     
    
    536 519
     
    
    537
    -    @log_calls('PluginManager')
    
    538 520
         def _activate_all_plugins(self):
    
    539 521
             '''
    
    540 522
             Activates all plugins in `plugins`.
    
    ... ... @@ -580,7 +562,6 @@ class PluginManager(metaclass=Singleton):
    580 562
         def _set_plugin_active_in_global_config(self, plugin, active=True):
    
    581 563
             app.config.set_per('plugins', plugin.short_name, 'active', active)
    
    582 564
     
    
    583
    -    @log_calls('PluginManager')
    
    584 565
         def scan_dir_for_plugins(self, path, scan_dirs=True, package=False):
    
    585 566
             r'''
    
    586 567
             Scans given directory for plugin classes.