Philipp Hörist pushed to branch master at gajim / gajim
Commits: 995b0172 by lovetox at 2020-06-02T08:29:01+02:00 Client: Remove unnecessary our-show events
The event gets raised when we receive the presence reflection
- - - - - fbe8c156 by lovetox at 2020-06-02T08:33:23+02:00 Client: Use NetworkEvent instead of OurShowEvent
- - - - - 3f6edc15 by lovetox at 2020-06-02T09:45:26+02:00 Refactor our-show event handlers
- - - - - e24f63c3 by lovetox at 2020-06-02T09:49:55+02:00 Remove unused code
- - - - - f8e137fa by lovetox at 2020-06-02T10:34:01+02:00 Update pre-push-tests.sh
- - - - -
9 changed files:
- gajim/chat_control_base.py - gajim/common/client.py - gajim/common/modules/presence.py - gajim/groupchat_control.py - gajim/gtk/notification.py - gajim/gui_interface.py - gajim/remote_control.py - gajim/roster_window.py - scripts/dev/pre-push-tests.sh
Changes:
===================================== gajim/chat_control_base.py ===================================== @@ -42,6 +42,7 @@ from gajim.common import i18n from gajim.common.i18n import _ from gajim.common.nec import EventHelper from gajim.common.helpers import AdditionalDataDict +from gajim.common.helpers import event_filter from gajim.common.contacts import GC_Contact from gajim.common.const import Chatstate from gajim.common.structs import OutgoingMessage @@ -434,14 +435,12 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): self.session.control = None self.session = None
- def _nec_our_status(self, obj): - if self.account != obj.conn.name: + @event_filter(['account']) + def _nec_our_status(self, event): + if event.show == 'connecting': return
- if obj.show == 'connecting': - return - - if obj.show == 'offline': + if event.show == 'offline': self.got_disconnected() else: self.got_connected()
===================================== gajim/common/client.py ===================================== @@ -40,7 +40,6 @@ from gajim.common.idle import Monitor from gajim.common.i18n import _
from gajim.common.connection_handlers import ConnectionHandlers -from gajim.common.connection_handlers_events import OurShowEvent from gajim.common.connection_handlers_events import MessageSentEvent
from gajim.gtk.util import open_window @@ -216,8 +215,8 @@ class Client(ConnectionHandlers):
def _on_resume_failed(self, _client, _signal_name): log.info('Resume failed') - app.nec.push_incoming_event(OurShowEvent( - None, conn=self, show='offline')) + app.nec.push_incoming_event(NetworkEvent( + 'our-show', account=self._account, show='offline')) self.get_module('Chatstate').enabled = False
def _on_resume_successful(self, _client, _signal_name): @@ -227,9 +226,6 @@ class Client(ConnectionHandlers): if self._status_sync_on_resume: self._status_sync_on_resume = False self.update_presence() - else: - app.nec.push_incoming_event( - OurShowEvent(None, conn=self, show=self._status))
def _set_client_available(self): self._set_state(ClientState.AVAILABLE) @@ -263,8 +259,8 @@ class Client(ConnectionHandlers): self.get_module('Chatstate').enabled = False self._reconnect = False self._after_disconnect() - app.nec.push_incoming_event(OurShowEvent( - None, conn=self, show='offline')) + app.nec.push_incoming_event(NetworkEvent( + 'our-show', account=self._account, show='offline')) self.process_ssl_errors()
elif domain in (StreamError.STREAM, StreamError.BIND): @@ -296,12 +292,12 @@ class Client(ConnectionHandlers): self._after_disconnect() self._schedule_reconnect() app.nec.push_incoming_event( - OurShowEvent(None, conn=self, show='error')) + NetworkEvent('our-show', account=self._account, show='error'))
else: self.get_module('Chatstate').enabled = False - app.nec.push_incoming_event(OurShowEvent( - None, conn=self, show='offline')) + app.nec.push_incoming_event(NetworkEvent( + 'our-show', account=self._account, show='offline')) self._after_disconnect()
def _after_disconnect(self): @@ -418,9 +414,6 @@ class Client(ConnectionHandlers):
self.get_module('MUC').update_presence()
- app.nec.push_incoming_event( - OurShowEvent(None, conn=self, show=status)) - def get_module(self, name): return modules.get(self._account, name)
@@ -542,7 +535,7 @@ class Client(ConnectionHandlers): self._set_state(ClientState.DISCONNECTED) self._disable_reconnect_timer() app.nec.push_incoming_event( - OurShowEvent(None, conn=self, show='offline')) + NetworkEvent('our-show', account=self._account, show='offline'))
if self._destroy_client: self._client.destroy()
===================================== gajim/common/modules/presence.py ===================================== @@ -90,7 +90,7 @@ class Presence(BaseModule): if properties.is_self_presence: app.nec.push_incoming_event( NetworkEvent('our-show', - conn=self._con, + account=self._account, show=properties.show.value)) return
===================================== gajim/groupchat_control.py ===================================== @@ -1128,12 +1128,11 @@ class GroupchatControl(ChatControlBase): msg_log_id=event.msg_log_id, displaymarking=event.displaymarking)
+ @event_filter(['account']) def _nec_our_status(self, event): - if self.account != event.conn.name: - return - + client = app.get_client(event.account) if (event.show == 'offline' and - not event.conn.state.is_reconnect_scheduled): + not client.state.is_reconnect_scheduled): self.got_disconnected()
if self.parent_win:
===================================== gajim/gtk/notification.py ===================================== @@ -132,9 +132,9 @@ class Notification(EventHelper): 'printed_gc_msg'): self._withdraw('new-message', event.account, event.jid)
- def _nec_our_status(self, obj): - if app.account_is_connected(obj.conn.name): - self._withdraw('connection-failed', obj.conn.name) + def _nec_our_status(self, event): + if app.account_is_connected(event.account): + self._withdraw('connection-failed', event.account)
@staticmethod def _get_icon_name(obj):
===================================== gajim/gui_interface.py ===================================== @@ -201,28 +201,21 @@ class Interface: def unblock_signed_in_notifications(account): app.block_signed_in_notifications[account] = False
- def handle_event_status(self, obj): # OUR status - #('STATUS', account, show) - account = obj.conn.name - if obj.show in ('offline', 'error'): + def handle_event_status(self, event): + if event.show in ('offline', 'error'): # TODO: Close all account windows pass
- if obj.show == 'offline': - app.block_signed_in_notifications[account] = True + if event.show == 'offline': + app.block_signed_in_notifications[event.account] = True else: # 30 seconds after we change our status to sth else than offline # we stop blocking notifications of any kind # this prevents from getting the roster items as 'just signed in' # contacts. 30 seconds should be enough time - GLib.timeout_add_seconds(30, self.unblock_signed_in_notifications, - account) - - if account in self.show_vcard_when_connect and obj.show not in ( - 'offline', 'error'): - action = '%s-profile' % account - app.app.activate_action(action, GLib.Variant('s', account)) - self.show_vcard_when_connect.remove(account) + GLib.timeout_add_seconds(30, + self.unblock_signed_in_notifications, + event.account)
@staticmethod def handle_gc_error(gc_control, pritext, sectext): @@ -2026,8 +2019,6 @@ class Interface: logind.enable() music_track.enable()
- self.show_vcard_when_connect = [] - idle.Monitor.set_interval(app.config.get('autoawaytime') * 60, app.config.get('autoxatime') * 60)
===================================== gajim/remote_control.py ===================================== @@ -382,8 +382,8 @@ class GajimRemote(Server): event_type, obj.properties.subject, obj.msg_log_id, obj.properties.nickname]))
- def on_our_status(self, obj): - self.raise_signal('AccountPresence', (obj.show, obj.conn.name)) + def on_our_status(self, event): + self.raise_signal('AccountPresence', (event.show, event.account))
def on_account_created(self, obj): self.raise_signal('NewAccount', (obj.conn.name, obj.account_info))
===================================== gajim/roster_window.py ===================================== @@ -2568,19 +2568,19 @@ class RosterWindow: """ self.rename_self_contact(obj.old_jid, obj.new_jid, obj.conn.name)
- def _nec_our_show(self, obj): + def _nec_our_show(self, event): model = self.status_combobox.get_model() iter_ = model.get_iter_from_string('6') - if obj.show == 'offline': + if event.show == 'offline': # sensitivity for this menuitem if app.get_number_of_connected_accounts() == 0: model[iter_][3] = False - self.application.set_account_actions_state(obj.conn.name) + self.application.set_account_actions_state(event.account) self.application.update_app_actions_state() else: # sensitivity for this menuitem model[iter_][3] = True - self.on_status_changed(obj.conn.name, obj.show) + self.on_status_changed(event.account, event.show)
def _nec_connection_type(self, obj): self.draw_account(obj.conn.name)
===================================== scripts/dev/pre-push-tests.sh ===================================== @@ -1,4 +1,15 @@ -SCRIPTDIR=$(dirname $0) +#!/bin/sh
+# exit when any command fails +set -e + +GREEN='\033[0;32m' + + +./scripts/dev/pylint-ci.sh gajim +echo "${GREEN}pylint: \t OK" mypy gajim -${SCRIPTDIR}/pylint-ci.sh --jobs=0 gajim +echo "${GREEN}mypy: \t\t OK" +codespell -I codespell.conf --skip="*__pycache__*,gajim/data/icons,gajim/data/sounds,gajim/data/emoticons" gajim +echo "${GREEN}codespell: \t OK" +echo "${GREEN}ready to push"
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/d572b3c529761794b6b01c50debdb02c...