Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: 6f4eb88a by wurstsalat at 2021-10-16T19:12:28+02:00 Notifications: Simplify message notifications
- - - - - 9460c72a by wurstsalat at 2021-10-17T14:18:26+02:00 Rework notification system
- - - - -
11 changed files:
- gajim/app_actions.py - gajim/common/client.py - gajim/common/connection_handlers_events.py - gajim/data/style/default-dark.css - gajim/data/style/default.css - gajim/gtk/call_widget.py - gajim/gtk/controls/base.py - gajim/gtk/filetransfer.py - gajim/gtk/notification.py - gajim/gtk/notification_manager.py - gajim/gui_interface.py
Changes:
===================================== gajim/app_actions.py ===================================== @@ -218,12 +218,12 @@ def on_file_transfers(_action, _param): def on_open_event(_action, param): dict_ = param.unpack() app.interface.handle_event( - dict_['account'], dict_['jid'], dict_['type_']) + dict_['account'], dict_['jid'], dict_['notif_detail'])
def on_mark_as_read(_action, param): dict_ = param.unpack() - account, jid, _ = dict_['account'], dict_['jid'], dict_['type_'] + account, jid = dict_['account'], dict_['jid'] app.window.mark_as_read(account, jid)
# Other Actions
===================================== gajim/common/client.py ===================================== @@ -266,7 +266,7 @@ def _on_password(password): app.nec.push_incoming_event( NetworkEvent('simple-notification', account=self._account, - type_='connection-failed', + notif_type='connection-failed', title=_('Authentication failed'), text=text or error))
===================================== gajim/common/connection_handlers_events.py ===================================== @@ -144,29 +144,6 @@ def generate(self): return True
-class NotificationEvent(nec.NetworkIncomingEvent): - - name = 'notification' - - def init(self): - self.account = None - self.contact = None - - self.notif_type = 'msg' - - self.popup_enabled = False - self.popup_event_type = '' - self.popup_msg_type = '' - self.popup_title = '' - self.popup_text = '' - self.icon_name = None - - self.sound_file = '' # Used by Triggers plugin only - self.sound_event = '' - - self.command = '' # Used by Triggers plugin only - - class NotificationEventOld(nec.NetworkIncomingEvent):
name = 'notification'
===================================== gajim/data/style/default-dark.css ===================================== @@ -70,19 +70,13 @@ .gajim-notify-signin { .gajim-notify-signout { color: rgb(134, 22, 22); } -.gajim-notify-status { - color: rgb(170, 170, 170); -} .gajim-notify-invite { color: rgb(224, 145, 42); } -.gajim-notify-ft-request { - color: rgb(240, 230, 140); -} -.gajim-notify-ft-error { +.gajim-notify-error { color: rgb(226, 33, 33); } -.gajim-notify-ft-complete { +.gajim-notify-success { color: rgb(139, 185, 48); } .gajim-notify-other {
===================================== gajim/data/style/default.css ===================================== @@ -64,19 +64,13 @@ .gajim-search-highlight { .gajim-notify-message { color: rgb(30, 144, 255); } -.gajim-notify-status { - color: rgb(170, 170, 170); -} .gajim-notify-invite { color: rgb(224, 145, 42); } -.gajim-notify-ft-request { - color: rgb(240, 230, 140); -} -.gajim-notify-ft-error { +.gajim-notify-error { color: rgb(226, 33, 33); } -.gajim-notify-ft-complete { +.gajim-notify-success { color: rgb(139, 185, 48); } .gajim-notify-other {
===================================== gajim/gtk/call_widget.py ===================================== @@ -23,8 +23,8 @@
from gajim.common import app from gajim.common.const import JingleState -from gajim.common.helpers import allow_showing_notification from gajim.common.i18n import _ +from gajim.common.nec import NetworkEvent
from .gstreamer import create_gtk_widget from .util import get_builder @@ -206,19 +206,16 @@ def _on_jingle_request(self, event): # There is no voice call running running yet self.emit('incoming-call', event)
- if allow_showing_notification(self._account): - heading = _('Incoming Call') - contact = self._client.get_module('Contacts').get_contact( - event.jid) - text = _('%s is calling') % contact.name - app.notification.popup( - heading, - event.jid, - self._account, - 'jingle-incoming', - icon_name='call-start-symbolic', - title=heading, - text=text) + contact = self._client.get_module('Contacts').get_contact( + event.jid) + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=self.account, + jid=self.contact.jid, + notif_type='jingle-incoming', + title=_('Incoming Call'), + text=_('%s is calling') % contact.name))
def _on_jingle_connected(self, event): session = self._client.get_module('Jingle').get_jingle_session(
===================================== gajim/gtk/controls/base.py ===================================== @@ -42,11 +42,10 @@ from gajim.common import i18n from gajim.common.i18n import _ from gajim.common.nec import EventHelper +from gajim.common.nec import NetworkEvent from gajim.common.helpers import AdditionalDataDict -from gajim.common.helpers import allow_showing_notification from gajim.common.const import KindConstant from gajim.common.structs import OutgoingMessage -from gajim.common.connection_handlers_events import NotificationEvent
from gajim.gui.conversation.view import ConversationView from gajim.gui.conversation.scrolled import ScrolledView @@ -1146,57 +1145,49 @@ def _notify(self, name, text, tim): if self._scrolled_view.get_autoscroll(): return
- popup_event_type = _('New Message') - popup_title = _('New message from %s') % name - needs_highlight = False + title = _('New message from %s') % name
if self.is_chat: - popup_msg_type = 'chat-message' - sound_event = 'first_message_received' + msg_type = 'chat-message' + sound = 'first_message_received'
if self.is_groupchat: - popup_msg_type = 'group-chat-message' - popup_title += f' ({self.contact.name})' + msg_type = 'group-chat-message' + title += f' ({self.contact.name})' needs_highlight = helpers.message_needs_highlight( text, self.contact.nickname, self._client.get_own_jid().bare) if needs_highlight: - sound_event = 'muc_message_highlight' + sound = 'muc_message_highlight' else: - sound_event = 'muc_message_received' + sound = 'muc_message_received' if not self.contact.can_notify(): - sound_event = None + sound = None
if self.is_privatechat: - popup_msg_type = 'private-chat-message' - popup_title += f' (private in {self.room_name})' - sound_event = 'first_message_received' + msg_type = 'private-chat-message' + title += f' (private in {self.room_name})' + sound = 'first_message_received'
# Is it a history message? Don't want sound-floods when we join. if tim is not None and time.mktime(time.localtime()) - tim > 1: - sound_event = None + sound = None
- popup_text = '' if app.settings.get('notification_preview_message'): if text.startswith('/me') or text.startswith('/me\n'): - popup_text = f'* {name} {text[3:]}' - else: - popup_text = text + text = f'* {name} {text[3:]}'
- popup_enabled = allow_showing_notification(self.account) if self.is_groupchat and not self.contact.can_notify(): - popup_enabled = False - - event = NotificationEvent( - None, - account=self.account, - jid=self.contact.jid, - popup_event_type=popup_event_type, - popup_msg_type=popup_msg_type, - popup_title=popup_title, - popup_text=popup_text, - popup_enabled=popup_enabled, - sound_event=sound_event) - app.nec.push_incoming_event(event) + return + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=self.account, + jid=self.contact.jid, + notif_type='incoming-message', + notif_detail=msg_type, + title=title, + text=text, + sound=sound))
def toggle_emoticons(self): """
===================================== gajim/gtk/filetransfer.py ===================================== @@ -74,8 +74,8 @@ def __init__(self):
self._ui = get_builder('filetransfers.ui') self.window = self._ui.file_transfers_window - show_notification = app.settings.get('notify_on_file_complete') - self._ui.notify_ft_complete.set_active(show_notification) + self._ui.notify_ft_complete.set_active( + app.settings.get('notify_on_file_complete')) self.model = Gtk.ListStore(str, str, str, str, str, int, int, str) self._ui.transfers_list.set_model(self.model) col = Gtk.TreeViewColumn() @@ -178,6 +178,18 @@ def _file_completed(self, event): event.file_props.sid, event.file_props.received_len)
+ if not app.settings.get('notify_on_file_complete'): + return + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=event.account, + jid=event.jid, + notif_type='file-transfer', + notif_detail='file-completed', + title=_('File Transfer Completed'), + text=_('File: %s') % event.file_props.name)) + def _file_error(self, event): self.set_status(event.file_props, 'stop')
@@ -189,17 +201,17 @@ def _file_hash_error(self, event): def _file_send_error(self, event): self.set_status(event.file_props, 'stop')
- if helpers.allow_showing_notification(event.account): - if app.window.is_chat_active(event.account, event.jid): - return - app.notification.popup( - _('File Transfer Error'), - event.jid, - event.account, - 'file-send-error', - 'dialog-error', - _('File Transfer Error'), - event.file_props.name) + if app.window.is_chat_active(event.account, event.jid): + return + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=event.account, + jid=event.jid, + notif_type='file-transfer', + notif_detail='file-send-error', + title=_('File Transfer Failed'), + text=_('File: %s') % event.file_props.name))
def _file_request_error(self, event): self.set_status(event.file_props, 'stop') @@ -212,21 +224,22 @@ def _file_request_error(self, event): return
if errno in (-4, -5): - msg_type = 'file-error' + notif_detail = 'file-error' else: - msg_type = 'file-request-error' + notif_detail = 'file-request-error'
- if helpers.allow_showing_notification(account): - if app.window.is_chat_active(account, event.jid): - return - app.notification.popup( - _('File Transfer Error'), - event.jid, - account, - msg_type, - 'dialog-error', - title=_('File Transfer Error'), - text=event.file_props.name) + if app.window.is_chat_active(account, event.jid): + return + + text = _('File: %s') % event.file_props.name + app.nec.push_incoming_event( + NetworkEvent('notification', + account=account, + jid=event.jid, + notif_type='file-transfer', + notif_detail=notif_detail, + title=_('File Transfer Failed'), + text=text))
def _file_request_received(self, event): account = event.conn.name @@ -243,17 +256,18 @@ def _file_request_received(self, event): self.add_transfer(account, contact, event.file_props) return
- if helpers.allow_showing_notification(account): - if app.window.is_chat_active(event.account, event.jid): - return - app.notification.popup( - _('File Transfer Request'), - event.jid, - account, - 'file-request-received', - icon_name='document-send', - title=_('File Transfer Request'), - text=_('%s wants to send you a file') % contact.name) + if app.window.is_chat_active(event.account, event.jid): + return + + text = _('%s wants to send you a file') % contact.name + app.nec.push_incoming_event( + NetworkEvent('notification', + account=account, + jid=event.jid, + notif_type='file-transfer', + notif_detail='file-request-received', + title=_('File Offered'), + text=text))
def _file_transfer_cancelled(self, event): file_props = None
===================================== gajim/gtk/notification.py ===================================== @@ -44,12 +44,21 @@
from .util import add_css_to_widget from .util import get_builder -from .util import get_icon_name from .util import get_monitor_scale_factor from .util import get_total_screen_geometry
log = logging.getLogger('gajim.gui.notification')
+NOTIFICATION_ICONS = { + 'incoming-message': 'gajim-chat_msg_recv', + 'group-chat-invitation': 'gajim-gc_invitation', + 'jingle-incoming': 'call-start-symbolic', + 'subscription_request': 'gajim-subscription_request', + 'unsubscribed': 'gajim-unsubscribed', + 'file-request-received': 'document-send', + 'file-send-error': 'dialog-error', +} +
class Notification(EventHelper): """ @@ -64,9 +73,10 @@ def __init__(self): self._detect_dbus_caps()
self.register_events([ - ('notification', ged.GUI2, self._nec_notification), + ('notification', ged.GUI2, self._on_notification), ('simple-notification', ged.GUI2, self._on_notification), - ('our-show', ged.GUI2, self._nec_our_status), + ('our-show', ged.GUI2, self._on_our_show), + ('connection-lost', ged.GUI2, self._on_connection_lost) ])
def _detect_dbus_caps(self): @@ -97,55 +107,79 @@ def on_proxy_ready(_source, res, _data=None): None, on_proxy_ready)
- def _nec_notification(self, event): - if event.popup_enabled and allow_showing_notification(event.account): - icon_name = self._get_icon_name(event) - self.popup( - event.popup_event_type, - str(event.jid), - event.account, - event.popup_msg_type, - icon_name=icon_name, - title=event.popup_title, - text=event.popup_text) - - if event.command: + def _on_notification(self, event): + if hasattr(event, 'command'): # Used by Triggers plugin try: exec_command(event.command, use_shell=True) except Exception: pass
- if event.sound_file: + if hasattr(event, 'sound_file'): # Allow override here, used by Triggers plugin play_sound_file(event.sound_file) - elif event.sound_event: - play_sound(event.sound_event, event.account) + elif hasattr(event, 'sound'): + play_sound(event.sound, event.account)
- def _on_notification(self, event): - self.popup(event.type_, - None, - event.account, - title=event.title, - text=event.text) + if not allow_showing_notification(event.account): + return
- def _nec_our_status(self, event): + if hasattr(event, 'notif_detail'): + notif_detail = event.notif_detail + else: + notif_detail = event.notif_type + + if hasattr(event, 'icon_name'): + icon_name = event.icon_name + else: + icon_name = NOTIFICATION_ICONS.get( + event.notif_detail, 'mail-message-new') + + self._issue_notification( + event.notif_type, + event.account, + str(event.jid), + notif_detail=notif_detail, + title=event.title, + text=event.text, + icon_name=icon_name) + + def _on_simple_notification(self, event): + if not allow_showing_notification(event.account): + return + + self._issue_notification( + event.notif_type, + event.account, + None, + title=event.title, + text=event.text) + + def _on_our_show(self, event): if app.account_is_connected(event.account): self._withdraw('connection-failed', event.account)
- @staticmethod - def _get_icon_name(event): - if event.notif_type == 'msg': - return 'gajim-chat_msg_recv' - - if event.notif_type == 'pres': - if event.transport_name is not None: - return '%s-%s' % (event.transport_name, event.show) - return get_icon_name(event.show) - return None - - def popup(self, event_type, jid, account, type_='', icon_name=None, - title=None, text=None, timeout=-1, room_jid=None): + def _on_connection_lost(self, event): + if not allow_showing_notification(event.conn.name): + return + + self._issue_notification( + 'connection-lost', + event.conn.name, + None, + title=event.title, + text=event.msg, + icon_name='gajim-connection_lost') + + def _issue_notification(self, + notif_type, + account, + jid, + notif_detail='', + title='', + text='', + icon_name=None, + timeout=-1): """ Notify a user of an event using GNotification and GApplication under Linux, Use PopupNotificationWindow under Windows @@ -160,8 +194,14 @@ def popup(self, event_type, jid, account, type_='', icon_name=None, if sys.platform == 'win32': self._withdraw() self._win32_active_popup = PopupNotification( - event_type, jid, account, type_, - icon_name, title, text, timeout) + notif_type, + account, + jid, + notif_detail, + title, + text, + icon_name, + timeout) self._win32_active_popup.connect('destroy', self._on_popup_destroy) return
@@ -176,36 +216,38 @@ def popup(self, event_type, jid, account, type_='', icon_name=None, if text is not None: notification.set_body(text) notif_id = None - if event_type in ( - _('New Message'), - _('Contact Changed Status'), _('File Transfer Request'), - _('File Transfer Error'), _('File Transfer Completed'), - _('File Transfer Stopped'), _('Group Chat Invitation'), - _('Connection Failed'), _('Subscription Request'), - _('Contact Unsubscribed'), _('Incoming Call')): + if notif_type in ( + 'incoming-message', + 'file-transfer', + 'group-chat-invitation', + 'subscription-request', + 'unsubscribed', + 'incoming-call', + 'connection-failed'): if 'actions' in self._daemon_capabilities: # Create Variant Dict dict_ = {'account': GLib.Variant('s', account), 'jid': GLib.Variant('s', jid), - 'type_': GLib.Variant('s', type_)} + 'notif_detail': GLib.Variant('s', notif_detail)} variant_dict = GLib.Variant('a{sv}', dict_) - action = 'app.{}-open-event'.format(account) - # Notification button + + # Add 'Open' action button to notification + action = f'app.{account}-open-event' notification.add_button_with_target( _('Open'), action, variant_dict) notification.set_default_action_and_target( action, variant_dict) - if event_type == _('New Message'): - action = 'app.{}-mark-as-read'.format(account) + + if notif_type == 'incoming-message': + # Add 'Mark as Read' action button to notification + action = f'app.{account}-mark-as-read' notification.add_button_with_target( _('Mark as Read'), action, variant_dict)
# Only one notification per JID - if event_type == _('Contact Changed Status'): - notif_id = self._make_id('contact-status-changed', account, jid) - elif event_type == _('Connection Failed'): + if notif_type == 'connection-failed': notif_id = self._make_id('connection-failed', account) - elif event_type == _('New Message'): + elif notif_type == 'incoming-message': if app.desktop_env == 'gnome': icon = self._get_avatar_for_notification(account, jid) notif_id = self._make_id('new-message', account, jid) @@ -238,8 +280,15 @@ def _make_id(*args):
class PopupNotification(Gtk.Window): - def __init__(self, event_type, jid, account, msg_type='', - icon_name=None, title=None, text=None, timeout=-1): + def __init__(self, + notif_type, + account, + jid, + notif_detail, + title, + text, + icon_name, + timeout): Gtk.Window.__init__(self) self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION) self.set_focus_on_map(False) @@ -248,37 +297,28 @@ def __init__(self, event_type, jid, account, msg_type='', self.set_decorated(False)
self._timeout_id = None - self.account = account - self.jid = jid - self.msg_type = msg_type + self._account = account + self._jid = jid + self._notif_type = notif_type
self._ui = get_builder('popup_notification_window.ui') self.add(self._ui.eventbox)
- client = app.get_client(account) - - if event_type in (_('New Message'), - _('New Private Message'), - _('New E-mail')): + if notif_detail == 'incoming-message': bg_color = app.css_config.get_value('.gajim-notify-message', StyleAttr.COLOR) - elif event_type == _('File Transfer Request'): - bg_color = app.css_config.get_value('.gajim-notify-ft-request', + elif notif_detail in ('file-error', + 'file-send-error', + 'file-request-error'): + bg_color = app.css_config.get_value('.gajim-notify-error', StyleAttr.COLOR) - elif event_type == _('File Transfer Error'): - bg_color = app.css_config.get_value('.gajim-notify-ft-error', + elif notif_detail in ('file-completed', 'file-stopped'): + bg_color = app.css_config.get_value('.gajim-notify-success', StyleAttr.COLOR) - elif event_type in (_('File Transfer Completed'), - _('File Transfer Stopped')): - bg_color = app.css_config.get_value('.gajim-notify-ft-complete', - StyleAttr.COLOR) - elif event_type == _('Group Chat Invitation'): + elif notif_detail == 'group-chat-invitation': bg_color = app.css_config.get_value('.gajim-notify-invite', StyleAttr.COLOR) - elif event_type == _('Contact Changed Status'): - bg_color = app.css_config.get_value('.gajim-notify-status', - StyleAttr.COLOR) - else: # Unknown event (shouldn't happen, but deal with it) + else: bg_color = app.css_config.get_value('.gajim-notify-other', StyleAttr.COLOR)
@@ -294,8 +334,9 @@ def __init__(self, event_type, jid, account, msg_type='', self._ui.event_type_label.set_markup(title)
if text is None: + client = app.get_client(account) contact = client.get_module('Contacts').get_contact(jid) - text = contact.name # default value of text + text = contact.name escaped_text = GLib.markup_escape_text(text) self._ui.event_description_label.set_markup(escaped_text)
@@ -326,7 +367,8 @@ def _on_close_button_clicked(self, _widget):
def _on_button_press(self, _widget, event): if event.button == 1: - app.interface.handle_event(self.account, self.jid, self.msg_type) + app.interface.handle_event( + self._account, self._jid, self._notif_type) self.destroy()
def _on_destroy(self, *args):
===================================== gajim/gtk/notification_manager.py ===================================== @@ -20,7 +20,7 @@ from gajim.common import app from gajim.common.const import AvatarSize from gajim.common.i18n import _ -from gajim.common.helpers import allow_showing_notification +from gajim.common.nec import NetworkEvent from gajim.common.helpers import get_groupchat_name from gajim.common.helpers import get_muc_context
@@ -137,20 +137,17 @@ def add_subscription_request(self, event): self.add(SubscriptionRequestRow( self._account, event.jid, event.status, event.user_nick))
- if allow_showing_notification(self._account): - event_type = _('Subscription Request') - contact = self._client.get_module('Contacts').get_contact( - event.jid) - text = _('%s asks you to share your status') % contact.name - app.notification.popup( - event_type, - event.jid, - self._account, - 'subscription-request', - 'gajim-subscription_request', - event_type, - text) - + contact = self._client.get_module('Contacts').get_contact( + event.jid) + text = _('%s asks you to share your status') % contact.name + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=self.account, + jid=self.contact.jid, + notif_type='subscription-request', + title=_('Subscription Request'), + text=text)) elif row.type == 'unsubscribed': self.remove(row)
@@ -159,19 +156,17 @@ def add_unsubscribed(self, event): if row is None: self.add(UnsubscribedRow(self._account, event.jid))
- if allow_showing_notification(self._account): - event_type = _('Contact Unsubscribed') - contact = self._client.get_module('Contacts').get_contact( - event.jid) - text = _('%s stopped sharing their status') % contact.name - app.notification.popup( - event_type, - event.jid, - self._account, - 'unsubscribed', - 'gajim-unsubscribed', - event_type, - text) + contact = self._client.get_module('Contacts').get_contact( + event.jid) + text = _('%s stopped sharing their status') % contact.name + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=self.account, + jid=self.contact.jid, + notif_type='unsubscribed', + title=_('Contact Unsubscribed'), + text=text)) elif row.type == 'subscribe': self.remove(row)
@@ -180,25 +175,22 @@ def add_invitation_received(self, event): if row is None: self.add(InvitationReceivedRow(self._account, event))
- if allow_showing_notification(self._account): - if get_muc_context(event.muc) == 'public': - jid = event.from_ - else: - jid = event.from_.bare - contact = self._client.get_module('Contacts').get_contact(jid) - event_type = _('Group Chat Invitation') - text = _('%(contact)s invited you to %(chat)s') % { - 'contact': contact.name, - 'chat': event.info.muc_name} - app.notification.popup( - event_type, - str(jid), - self._account, - 'gc-invitation', - 'gajim-gc_invitation', - event_type, - text, - room_jid=event.muc) + if get_muc_context(event.muc) == 'public': + jid = event.from_ + else: + jid = event.from_.bare + contact = self._client.get_module('Contacts').get_contact(jid) + text = _('%(contact)s invited you to %(chat)s') % { + 'contact': contact.name, + 'chat': event.info.muc_name} + + app.nec.push_incoming_event( + NetworkEvent('notification', + account=self.account, + jid=self.contact.jid, + notif_type='group-chat-invitation', + title=_('Group Chat Invitation'), + text=text))
def add_invitation_declined(self, event): row = self._get_notification_row(event.muc)
===================================== gajim/gui_interface.py ===================================== @@ -195,7 +195,6 @@ def _create_core_handlers_list(self): self.handlers = { 'information': [self.handle_event_information], 'iq-error-received': [self.handle_event_iq_error], - 'connection-lost': [self.handle_event_connection_lost], 'plain-connection': [self.handle_event_plain_connection], 'http-auth-received': [self.handle_event_http_auth], 'password-required': [self.handle_event_password_required], @@ -229,21 +228,22 @@ def _register_core_handlers(self): prio, event_handler)
- def handle_event(self, account, jid, type_): + def handle_event(self, account, jid, notif_detail): jid = JID.from_string(jid)
- if type_ in ('connection-lost', 'connection-failed'): + if notif_detail in ('connection-lost', 'connection-failed'): app.window.show_account_page(account) - elif type_ in ('group-chat-message', 'private-chat-message'): + elif notif_detail == 'private-chat-message': + app.window.select_chat(account, jid) + elif notif_detail in ('chat-message', 'group-chat-message'): app.window.select_chat(account, jid.bare) - elif type_ in ('chat-message', ''): - # '' is for log in/out notifications + elif notif_detail == 'jingle-incoming': app.window.select_chat(account, jid.bare) - elif type_ == 'jingle-incoming': + elif notif_detail == 'file-request-received': app.window.select_chat(account, jid.bare) - elif type_ in ('subscription-request', - 'unsubscribed', - 'gc-invitation'): + elif notif_detail in ('subscription-request', + 'unsubscribed', + 'group-chat-invitation'): app.window.show_account_page(account)
app.window.present() @@ -278,19 +278,6 @@ def handle_event_iq_error(event): if ctrl and ctrl.is_groupchat: ctrl.add_info_message(f'Error: {event.properties.error}')
- @staticmethod - def handle_event_connection_lost(event): - # ('CONNECTION_LOST', account, [title, text]) - account = event.conn.name - app.notification.popup( - _('Connection Failed'), - account, - account, - 'connection-lost', - 'gajim-connection_lost', - event.title, - event.msg) - @staticmethod def handle_event_plain_connection(event): ConfirmationDialog( @@ -580,11 +567,13 @@ def handle_event_file_rcv_completed(self, account, file_props): app.nec.push_incoming_event( NetworkEvent('file-completed', file_props=file_props, + account=account, jid=jid.bare)) else: app.nec.push_incoming_event( NetworkEvent('file-error', file_props=file_props, + account=account, jid=jid.bare))
# End jingle session @@ -601,11 +590,13 @@ def handle_event_file_rcv_completed(self, account, file_props): app.nec.push_incoming_event( NetworkEvent('file-completed', file_props=file_props, + account=account, jid=jid.bare)) else: app.nec.push_incoming_event( NetworkEvent('file-error', file_props=file_props, + account=account, jid=jid.bare))
def __compare_hashes(self, account, file_props): @@ -618,19 +609,21 @@ def __compare_hashes(self, account, file_props): hash_ = hashes.calculateHash(file_props.algo, file_) file_.close() # File is corrupt if the calculated hash differs from the received hash + jid = JID.from_string(file_props.sender) if file_props.hash_ == hash_: app.nec.push_incoming_event( NetworkEvent('file-completed', - file_props=file_props)) + file_props=file_props, + account=account, + jid=jid.bare)) else: # Wrong hash, we need to get the file again! file_props.error = -10 - jid = JID.from_string(file_props.sender) app.nec.push_incoming_event( NetworkEvent('file-hash-error', file_props=file_props, - jid=jid.bare, - account=account)) + account=account, + jid=jid.bare)) # End jingle session client = app.get_client(account) session = client.get_module('Jingle').get_jingle_session(
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/6c9ba7ff22fb4a47b7b1f7f6b25c23d2...