Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
eab57243 by wurstsalat at 2021-10-19T18:19:43+02:00
Don't fail if sound event is None
- - - - -
1 changed file:
- gajim/common/helpers.py
Changes:
=====================================
gajim/common/helpers.py
=====================================
@@ -455,6 +455,8 @@ def get_contact_dict_for_account(account):
def play_sound(sound_event, account, force=False):
+ if sound_event is None:
+ return
if force or allow_sound_notification(account, sound_event):
play_sound_file(
app.settings.get_soundevent_settings(sound_event)['path'])
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/eab5724364784210815d766d799ba794…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/eab5724364784210815d766d799ba794…
You're receiving this email because of your account on dev.gajim.org.
Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
e47d9712 by wurstsalat at 2021-10-16T16:23:43+02:00
Main Window: Simplify _on_window_delete()
- - - - -
1 changed file:
- gajim/gtk/main.py
Changes:
=====================================
gajim/gtk/main.py
=====================================
@@ -282,23 +282,25 @@ def _on_window_motion_notify(self, _widget, _event):
def _on_window_delete(self, _widget, _event):
# Main window X button was clicked
- if (not app.settings.get('quit_on_main_window_x_button') and
- ((app.interface.systray_enabled and
- app.settings.get('trayicon') != 'on_event') or
- app.settings.get('allow_hide_roster'))):
- save_main_window_position()
- if (os.name == 'nt' or
- app.settings.get('hide_on_main_window_x_button')):
- self.hide()
- else:
- self.iconify()
- elif app.settings.get('quit_on_main_window_x_button'):
+ if app.settings.get('quit_on_main_window_x_button'):
self.quit()
else:
+ if (app.settings.get('allow_hide_roster') or
+ (app.interface.systray_enabled and
+ app.settings.get('trayicon') != 'on_event')):
+ save_main_window_position()
+ if (os.name == 'nt' or
+ app.settings.get('hide_on_main_window_x_button')):
+ self.hide()
+ else:
+ self.iconify()
+ return True
+
def _on_ok(is_checked):
if is_checked:
app.settings.set('quit_on_main_window_x_button', True)
self.quit()
+
ConfirmationCheckDialog(
_('Quit Gajim'),
_('You are about to quit Gajim'),
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/e47d97129bbece2ac204a89b7e1ba140…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/e47d97129bbece2ac204a89b7e1ba140…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
e133c4f0 by lovetox at 2021-10-16T15:48:02+02:00
AccountWizard: Handle all errors during disconnect
Fixes #10658
- - - - -
1 changed file:
- gajim/gtk/account_wizard.py
Changes:
=====================================
gajim/gtk/account_wizard.py
=====================================
@@ -363,7 +363,10 @@ def _on_disconnected(self, client, _signal_name):
# by the server. This ignores all stream errors if we already
# know that we succeeded.
if self.get_current_page() != 'success':
- self._show_error_page(_('Error'), _('Error'), error)
+ self._show_error_page(_('Error'), _('Error'), text or error)
+
+ else:
+ self._show_error_page(_('Error'), _('Error'), text or error)
self.get_page('form').remove_form()
self._client.destroy()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/e133c4f0fb91213069268a9d8af379ed…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/e133c4f0fb91213069268a9d8af379ed…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
2b8b5a22 by lovetox at 2021-10-16T15:41:14+02:00
Dispatcher: Pass str as error instead of exception
- - - - -
1 changed file:
- nbxmpp/dispatcher.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -241,7 +241,7 @@ class StanzaDispatcher(Observable):
self._parser.Parse(data)
except (ExpatError, ValueError) as error:
self._log.error('XML parsing error: %s', error)
- self.notify('parsing-error', error)
+ self.notify('parsing-error', str(error))
return
# end stream:stream tag received
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/2b8b5a2262c14901d5a514c0…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/2b8b5a2262c14901d5a514c0…
You're receiving this email because of your account on dev.gajim.org.
Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
83bb932d by wurstsalat at 2021-10-16T15:12:31+02:00
Events: Remove usage of chat message events
- - - - -
fc2d8132 by wurstsalat at 2021-10-16T15:15:51+02:00
Remove obsolete common/events.py
- - - - -
9 changed files:
- gajim/common/app.py
- − gajim/common/events.py
- gajim/gtk/accounts.py
- gajim/gtk/controls/base.py
- gajim/gtk/controls/chat.py
- gajim/gtk/main.py
- gajim/gtk/notification.py
- gajim/gui_interface.py
- gajim/remote_control.py
Changes:
=====================================
gajim/common/app.py
=====================================
@@ -48,7 +48,6 @@
from gajim.common import ged as ged_module
from gajim.common.i18n import LANG
from gajim.common.const import Display
-from gajim.common.events import Events
from gajim.common.types import NetworkEventsControllerT # pylint: disable=unused-import
from gajim.common.types import InterfaceT # pylint: disable=unused-import
from gajim.common.types import ConnectionT # pylint: disable=unused-import
@@ -106,8 +105,6 @@ def __init__(self):
# list of contacts that has just signed out
to_be_removed = {} # type: Dict[str, List[str]]
-events = Events()
-
notification = None
# list of our nick names in each account
=====================================
gajim/common/events.py deleted
=====================================
@@ -1,280 +0,0 @@
-# Copyright (C) 2006 Jean-Marie Traissard <jim AT lapin.org>
-# Nikos Kouremenos <kourem AT gmail.com>
-# Copyright (C) 2006-2014 Yann Leboulanger <asterix AT lagaule.org>
-# Copyright (C) 2007 Julien Pivotto <roidelapluie AT gmail.com>
-# Copyright (C) 2007-2008 Stephan Erb <steve-e AT h3c.de>
-# Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
-# Jonathan Schleifer <js-gajim AT webkeks.org>
-#
-# This file is part of Gajim.
-#
-# Gajim is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; version 3 only.
-#
-# Gajim is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
-
-import time
-
-
-class Event:
- def __init__(self, time_=None):
- """
- type_ in chat-message, group-chat-message, private-chat-message,
-
- parameters is (per type_):
- *-chat-message: [message, subject, control, msg_log_id]
- """
- if time_:
- self.time_ = time_
- else:
- self.time_ = time.time()
- # Set when adding the event
- self.jid = None
- self.account = None
-
-
-class ChatMsgEvent(Event):
-
- type_ = 'chat-message'
-
- def __init__(self,
- message,
- subject,
- control,
- msg_log_id,
- time_=None,
- message_id=None,
- stanza_id=None):
- Event.__init__(self, time_)
- self.message = message
- self.subject = subject
- self.control = control
- self.msg_log_id = msg_log_id
- self.message_id = message_id
- self.stanza_id = stanza_id
-
-
-class GroupChatMsgEvent(ChatMsgEvent):
-
- type_ = 'group-chat-message'
-
-
-class PrivateChatMsgEvent(ChatMsgEvent):
-
- type_ = 'private-chat-message'
-
-
-class Events:
- def __init__(self):
- self._events = {} # list of events {acct: {jid1: [E1, E2]}, }
- self._event_added_listeners = []
- self._event_removed_listeners = []
-
- def event_added_subscribe(self, listener):
- """
- Add a listener when an event is added to the queue
- """
- if listener not in self._event_added_listeners:
- self._event_added_listeners.append(listener)
-
- def event_added_unsubscribe(self, listener):
- """
- Remove a listener when an event is added to the queue
- """
- if listener in self._event_added_listeners:
- self._event_added_listeners.remove(listener)
-
- def event_removed_subscribe(self, listener):
- """
- Add a listener when an event is removed from the queue
- """
- if listener not in self._event_removed_listeners:
- self._event_removed_listeners.append(listener)
-
- def event_removed_unsubscribe(self, listener):
- """
- Remove a listener when an event is removed from the queue
- """
- if listener in self._event_removed_listeners:
- self._event_removed_listeners.remove(listener)
-
- def fire_event_added(self, event):
- for listener in self._event_added_listeners:
- listener(event)
-
- def fire_event_removed(self, event_list):
- for listener in self._event_removed_listeners:
- listener(event_list)
-
- def add_account(self, account):
- self._events[account] = {}
-
- def get_accounts(self):
- return self._events.keys()
-
- def remove_account(self, account):
- del self._events[account]
-
- def add_event(self, account, jid, event):
- if account not in self._events:
- self._events[account] = {jid: [event]}
- elif jid not in self._events[account]:
- self._events[account][jid] = [event]
- else:
- self._events[account][jid].append(event)
-
- event.jid = jid
- event.account = account
-
- self.fire_event_added(event)
-
- def remove_account_events(self, account):
- if account not in self._events:
- return
-
- account_events = self.get_events(account)
- for jid, _events in account_events.items():
- self.remove_events(account, jid)
-
- def remove_events(self, account, jid, event=None, types=None):
- """
- If event is not specified, remove all events from this jid, optionally
- only from given type return True if no such event found
- """
- if types is None:
- types = []
- if account not in self._events:
- return True
- if jid not in self._events[account]:
- return True
-
- if event: # remove only one event
- if event in self._events[account][jid]:
- if len(self._events[account][jid]) == 1:
- del self._events[account][jid]
- else:
- self._events[account][jid].remove(event)
- self.fire_event_removed([event])
- return False
- return True
- if types:
- new_list = [] # list of events to keep
- removed_list = [] # list of removed events
- for ev in self._events[account][jid]:
- if ev.type_ not in types:
- new_list.append(ev)
- else:
- removed_list.append(ev)
- if len(new_list) == len(self._events[account][jid]):
- return True
-
- if new_list:
- self._events[account][jid] = new_list
- else:
- del self._events[account][jid]
- self.fire_event_removed(removed_list)
- return False
-
- # No event nor type given, remove them all
- removed_list = self._events[account][jid]
- del self._events[account][jid]
- self.fire_event_removed(removed_list)
-
- def change_jid(self, account, old_jid, new_jid):
- if account not in self._events:
- return
- if old_jid not in self._events[account]:
- return
- if new_jid in self._events[account]:
- self._events[account][new_jid] += self._events[account][old_jid]
- else:
- self._events[account][new_jid] = self._events[account][old_jid]
- del self._events[account][old_jid]
-
- def get_events(self, account, jid=None, types=None):
- """
- Return all events from the given account of the form:
- {jid1: [], jid2: []}.
- If jid is given, returns all events from the given jid in a list:
- []
- optionally only from given type
- """
- if types is None:
- types = []
- if account not in self._events:
- return []
-
- if not jid:
- events_list = {}
- for jid_ in self._events[account]:
- events = []
- for ev in self._events[account][jid_]:
- if not types or ev.type_ in types:
- events.append(ev)
- if events:
- events_list[jid_] = events
- return events_list
-
- if jid not in self._events[account]:
- return []
-
- events_list = []
- for ev in self._events[account][jid]:
- if not types or ev.type_ in types:
- events_list.append(ev)
- return events_list
-
- def get_all_events(self, types=None):
- accounts = self._events.keys()
- events = []
- for account in accounts:
- for jid in self._events[account]:
- for event in self._events[account][jid]:
- if types is None or event.type_ in types:
- events.append(event)
- return events
-
- def get_first_event(self, account=None, jid=None, type_=None):
- """
- Return the first event of type type_ if given
- """
- if not account:
- return self._get_first_event_with_attribute(self._events)
-
- events_list = self.get_events(account, jid, type_)
- # be sure it's bigger than latest event
- first_event_time = time.time() + 1
- first_event = None
- for event in events_list:
- if event.time_ < first_event_time:
- first_event_time = event.time_
- first_event = event
- return first_event
-
- @staticmethod
- def _get_first_event_with_attribute(events):
- """
- Get the first event.
- events is in the form {account1: {jid1: [ev1, ev2], },. }
- """
- # be sure it's bigger than latest event
- first_event_time = time.time() + 1
- first_account = None
- first_jid = None
- first_event = None
- for account in events:
- for jid in events[account]:
- for event in events[account][jid]:
- if event.time_ < first_event_time:
- first_event_time = event.time_
- first_account = account
- first_jid = jid
- first_event = event
- return first_account, first_jid, first_event
=====================================
gajim/gtk/accounts.py
=====================================
@@ -147,10 +147,6 @@ def _get_relogin_settings(account):
@staticmethod
def on_remove_account(account):
- if app.events.get_events(account):
- app.interface.raise_dialog('unread-events-on-remove-account')
- return
-
if app.settings.get_account_setting(account, 'is_zeroconf'):
# Should never happen as button is insensitive
return
=====================================
gajim/gtk/controls/base.py
=====================================
@@ -40,9 +40,6 @@
from gajim.common import helpers
from gajim.common import ged
from gajim.common import i18n
-from gajim.common.events import ChatMsgEvent
-from gajim.common.events import GroupChatMsgEvent
-from gajim.common.events import PrivateChatMsgEvent
from gajim.common.i18n import _
from gajim.common.nec import EventHelper
from gajim.common.helpers import AdditionalDataDict
@@ -1140,9 +1137,6 @@ def add_message(self,
# Issue notification
self._notify(name, text, tim)
- # Add message event
- self._add_message_event(text, msg_log_id, message_id, stanza_id)
-
# Send chat marker if we’re actively following the chat
chat_active = app.window.is_chat_active(
self.account, self.contact.jid)
@@ -1206,29 +1200,6 @@ def _notify(self, name, text, tim):
sound_event=sound_event)
app.nec.push_incoming_event(event)
- def _add_message_event(self, text, msg_log_id, message_id, stanza_id):
- if app.window.is_chat_active(self.account, self.contact.jid):
- if self._scrolled_view.get_autoscroll():
- return
-
- if self.is_groupchat:
- event_type = GroupChatMsgEvent
- event = 'gc_message_received'
- else:
- if self.is_chat:
- event_type = ChatMsgEvent
- else:
- event_type = PrivateChatMsgEvent
- event = 'message_received'
-
- event = event_type(text,
- '',
- self,
- msg_log_id,
- message_id=message_id,
- stanza_id=stanza_id)
- app.events.add_event(self.account, str(self.contact.jid), event)
-
def toggle_emoticons(self):
"""
Hide show emoticons_button
=====================================
gajim/gtk/controls/chat.py
=====================================
@@ -638,6 +638,7 @@ def shutdown(self):
app.check_finalize(self)
def allow_shutdown(self, _method, on_yes, on_no):
+ # TODO: app.last_message_time is not set anywhere
time_ = app.last_message_time[self.account][self.contact.jid]
# 2 seconds
if time.time() - time_ < 2:
=====================================
gajim/gtk/main.py
=====================================
@@ -631,28 +631,21 @@ def on_continue(message):
if message is None:
# user pressed Cancel to change status message dialog
return
- # check if we have unread messages
- # TODO:
- # unread = app.events.get_nb_events()
-
- # for event in app.events.get_all_events(['group-chat-message']):
- # contact = app.contacts.get_groupchat_contact(event.jid)
- # if contact is None or not contact.can_notify():
- # unread -= 1
-
- # if unread:
- # ConfirmationDialog(
- # _('Unread Messages'),
- # _('You still have unread messages'),
- # _('Messages will only be available for reading them later '
- # 'if storing chat history is enabled and if the contact '
- # 'is in your contact list.'),
- # [DialogButton.make('Cancel'),
- # DialogButton.make('Remove',
- # text=_('_Quit'),
- # callback=on_continue2,
- # args=[message])]).show()
- # return
+
+ # Check for unread messages
+ if self.get_total_unread_count():
+ ConfirmationDialog(
+ _('Unread Messages'),
+ _('You still have unread messages'),
+ _('Messages will only be available for reading them later '
+ 'if storing chat history is enabled and if the contact '
+ 'is in your contact list.'),
+ [DialogButton.make('Cancel'),
+ DialogButton.make('Remove',
+ text=_('_Quit'),
+ callback=on_continue2,
+ args=[message])]).show()
+ return
on_continue2(message)
if get_msg and ask_for_status_message('offline'):
=====================================
gajim/gtk/notification.py
=====================================
@@ -69,8 +69,6 @@ def __init__(self):
('our-show', ged.GUI2, self._nec_our_status),
])
- app.events.event_removed_subscribe(self._on_event_removed)
-
def _detect_dbus_caps(self):
if sys.platform in ('win32', 'darwin'):
return
@@ -131,14 +129,6 @@ def _on_notification(self, event):
title=event.title,
text=event.text)
- def _on_event_removed(self, event_list):
- for event in event_list:
- if event.type_ in ('chat-message',
- 'group-chat-message',
- 'private-chat-message',
- 'jingle-incoming'):
- self._withdraw('new-message', event.account, event.jid)
-
def _nec_our_status(self, event):
if app.account_is_connected(event.account):
self._withdraw('connection-failed', event.account)
=====================================
gajim/gui_interface.py
=====================================
@@ -235,15 +235,12 @@ def handle_event(self, account, jid, type_):
if type_ in ('connection-lost', 'connection-failed'):
app.window.show_account_page(account)
- app.events.remove_events(account, jid, types=type_)
elif type_ in ('group-chat-message', 'private-chat-message'):
app.window.select_chat(account, jid.bare)
- app.events.remove_events(account, jid, types=type_)
elif type_ in ('chat-message', ''):
# '' is for log in/out notifications
app.window.select_chat(account, jid.bare)
app.last_message_time[account][jid] = 0 # long time ago
- app.events.remove_events(account, jid, types=type_)
elif type_ == 'jingle-incoming':
app.window.select_chat(account, jid.bare)
elif type_ in ('subscription-request',
@@ -856,8 +853,6 @@ def disable_account(self, account):
'account-disabled',
account=account))
- app.events.remove_account_events(account)
-
if account == app.ZEROCONF_ACC_NAME:
app.connections[account].disable_account()
app.connections[account].cleanup()
=====================================
gajim/remote_control.py
=====================================
@@ -784,20 +784,7 @@ def _contacts_as_dbus_structure(self, bare_contact):
return contact_dict
def get_unread_msgs_number(self):
- # TODO:
- return 0
-
- unread = app.events.get_nb_events()
- for event in app.events.get_all_events(['group-chat-message']):
- client = app.get_client(event.account)
- contact = client.get_module('Contacts').get_contact(
- event.jid, groupchat=True)
-
- if not contact.can_notify():
- unread -= 1
- continue
-
- return str(unread)
+ return str(app.window.get_total_unread_count())
def start_chat(self, jid=''):
app.app.activate_action('start-chat', GLib.Variant('s', jid))
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/ef621f9987bc025cd0ae1bb9b95a51f…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/ef621f9987bc025cd0ae1bb9b95a51f…
You're receiving this email because of your account on dev.gajim.org.