gajim.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2026
October
September
August
July
June
May
April
March
February
January
2025
December
November
October
September
August
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
List overview
Download
Commits
January 2022
----- 2026 -----
October 2026
September 2026
August 2026
July 2026
June 2026
May 2026
April 2026
March 2026
February 2026
January 2026
----- 2025 -----
December 2025
November 2025
October 2025
September 2025
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
commits@gajim.org
1 participants
161 discussions
Start a n
N
ew thread
[Git][gajim/gajim][master] 3 commits: Remove dead code
by Philipp Hörist (@lovetox)
23 Jan '22
23 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: afd89099 by lovetox at 2022-01-23T20:33:06+01:00 Remove dead code - - - - - b9335eaf by lovetox at 2022-01-23T20:33:06+01:00 Main: Refactor event handling - Add dedicated methods for some events - Add type annotations - Events: Use JID object instead of string - - - - - 28847ed8 by lovetox at 2022-01-23T20:41:05+01:00 Main: Reduce event imports - - - - - 11 changed files: - gajim/common/app.py - gajim/common/events.py - gajim/common/jingle_ft.py - gajim/common/jingle_session.py - gajim/common/modules/mam.py - gajim/common/modules/message.py - gajim/common/modules/presence.py - gajim/gtk/chat_list.py - gajim/gtk/main.py - gajim/gui_interface.py - pyrightconfig.json Changes: ===================================== gajim/common/app.py ===================================== @@ -93,9 +93,6 @@ def __init__(self): # {account: {room_jid: {'invities': []}}} automatic_rooms: dict[str, dict[str, dict[str, list[str]]]] = {} -# list of contacts that has just signed in -newly_added: dict[str, list[str]] = {} - # list of contacts that has just signed out to_be_removed: dict[str, list[str]] = {} ===================================== gajim/common/events.py ===================================== @@ -37,6 +37,21 @@ from gajim.common.client import Client +MainEventT = Union['PresenceReceived', + 'MessageSent', + 'MamMessageReceived', + 'GcMessageReceived', + 'MessageUpdated', + 'ReceiptReceived', + 'DisplayedReceived', + 'MessageError', + 'MucDiscoUpdate', + 'JingleConnectedReceived', + 'JingleDisconnectedReceived', + 'JingleErrorReceived', + 'FileRequestSent'] + + @dataclass class ApplicationEvent: name: str @@ -130,7 +145,7 @@ class MusicTrackChanged(ApplicationEvent): class MessageSent(ApplicationEvent): name: str = field(init=False, default='message-sent') account: str - jid: str + jid: JID message: str message_id: str chatstate: Optional[str] @@ -200,7 +215,7 @@ class FileRequestSent(ApplicationEvent): name: str = field(init=False, default='file-request-sent') account: str file_props: FileProp - jid: str + jid: JID @dataclass @@ -342,7 +357,7 @@ class ArchivingIntervalFinished(ApplicationEvent): class MessageUpdated(ApplicationEvent): name: str = field(init=False, default='message-updated') account: str - jid: str + jid: JID msgtxt: str properties: Any correct_id: str @@ -352,7 +367,7 @@ class MessageUpdated(ApplicationEvent): class MamMessageReceived(ApplicationEvent): name: str = field(init=False, default='mam-message-received') account: str - jid: str + jid: JID msgtxt: str properties: Any additional_data: AdditionalDataDict @@ -368,7 +383,7 @@ class MessageReceived(ApplicationEvent): conn: 'Client' stanza: Any account: str - jid: str + jid: JID msgtxt: str properties: Any additional_data: AdditionalDataDict @@ -392,7 +407,7 @@ class GcMessageReceived(MessageReceived): class MessageError(ApplicationEvent): name: str = field(init=False, default='message-error') account: str - jid: str + jid: JID room_jid: str message_id: str error: Any @@ -452,7 +467,7 @@ class SearchResultReceivedEvent(ApplicationEvent): class ReceiptReceived(ApplicationEvent): name: str = field(init=False, default='receipt-received') account: str - jid: str + jid: JID receipt_id: str @@ -462,7 +477,7 @@ class JingleEvent(ApplicationEvent): conn: 'Client' account: str fjid: str - jid: str + jid: JID sid: str resource: str jingle_session: Any @@ -571,7 +586,7 @@ class PresenceReceived(ApplicationEvent): need_add_in_roster: bool popup: bool ptype: str - jid: str + jid: JID resource: str id_: str fjid: str @@ -622,7 +637,7 @@ class FileRequestReceivedEvent(ApplicationEvent): id_: str fjid: str account: str - jid: str + jid: JID file_props: FileProp ===================================== gajim/common/jingle_ft.py ===================================== @@ -181,7 +181,7 @@ def _raise_event(self, stanza, content): fjid = con.get_module('Bytestream')._ft_get_from(stanza) account = con.name jid = app.get_jid_without_resource(fjid) - + jid = JID.from_string(jid) if not content: return ===================================== gajim/common/jingle_session.py ===================================== @@ -902,7 +902,7 @@ def __transport_accept(self, transport): def _raise_event(self, name: str, **kwargs): jid, resource = app.get_room_and_nick_from_fjid( str(self.peerjid)) - + jid = JID.from_string(jid) event_class = JINGLE_EVENTS[name] app.ged.raise_event( ===================================== gajim/common/modules/mam.py ===================================== @@ -260,7 +260,7 @@ def _mam_message_received(self, _con, stanza, properties): event_attr = { 'account': self._account, - 'jid': str(properties.jid.bare), + 'jid': properties.jid.new_as_bare(), 'msgtxt': properties.body, 'properties': properties, 'additional_data': additional_data, ===================================== gajim/common/modules/message.py ===================================== @@ -179,7 +179,7 @@ def _message_received(self, _con, stanza, properties): 'account': self._account, 'additional_data': additional_data, 'fjid': fjid, - 'jid': fjid if properties.is_muc_pm else jid, + 'jid': from_ if properties.is_muc_pm else from_.new_as_bare(), 'resource': resource, 'stanza_id': stanza_id, 'unique_id': stanza_id or message_id, ===================================== gajim/common/modules/presence.py ===================================== @@ -125,7 +125,7 @@ def _presence_received(self, _con, stanza, properties): 'need_add_in_roster': False, 'popup': False, 'ptype': properties.type.value, - 'jid': properties.jid.bare, + 'jid': properties.jid.new_as_bare(), 'resource': properties.jid.resource, 'id_': properties.id, 'fjid': str(properties.jid), ===================================== gajim/gtk/chat_list.py ===================================== @@ -495,7 +495,7 @@ def _on_jingle_request_received(self, def _on_file_request_received(self, event: events.FileRequestReceivedEvent ) -> None: - row = self._chats.get((event.account, JID.from_string(event.jid))) + row = self._chats.get((event.account, event.jid)) if row is None: return row.set_timestamp(time.time()) ===================================== gajim/gtk/main.py ===================================== @@ -29,23 +29,12 @@ from nbxmpp import JID from gajim.common import app +from gajim.common import events from gajim.common import ged from gajim.common.const import Direction -from gajim.common.events import ApplicationEvent -from gajim.common.events import MucAdded -from gajim.common.events import HttpAuth -from gajim.common.events import PasswordRequired -from gajim.common.events import PlainConnection -from gajim.common.events import RosterItemExchangeEvent -from gajim.common.events import AllowGajimUpdateCheck -from gajim.common.events import GajimUpdateAvailable -from gajim.common.events import AccountEnabled -from gajim.common.events import AccountDisabled -from gajim.common.events import ShowChanged -from gajim.common.events import SignedIn +from gajim.common.ged import EventHelper from gajim.common.helpers import ask_for_status_message from gajim.common.i18n import _ -from gajim.common.ged import EventHelper from gajim.common.modules.bytestream import is_transfer_active from .account_side_bar import AccountSideBar @@ -110,22 +99,19 @@ def __init__(self) -> None: self.register_events([ ('presence-received', ged.GUI1, self._on_event), ('message-sent', ged.GUI1, self._on_event), - ('message-received', ged.CORE, self._on_event), + ('message-received', ged.CORE, self._on_message_received), ('mam-message-received', ged.CORE, self._on_event), ('gc-message-received', ged.CORE, self._on_event), ('message-updated', ged.CORE, self._on_event), ('receipt-received', ged.GUI1, self._on_event), ('displayed-received', ged.GUI1, self._on_event), ('message-error', ged.GUI1, self._on_event), - ('muc-creation-failed', ged.GUI1, self._on_event), - ('muc-self-presence', ged.GUI1, self._on_event), - ('muc-voice-request', ged.GUI1, self._on_event), ('muc-disco-update', ged.GUI1, self._on_event), - ('jingle-request-received', ged.GUI1, self._on_event), + ('jingle-request-received', ged.GUI1, self._on_jingle_request), ('jingle-connected-received', ged.GUI1, self._on_event), ('jingle-disconnected-received', ged.GUI1, self._on_event), ('jingle-error-received', ged.GUI1, self._on_event), - ('file-request-received', ged.GUI1, self._on_event), + ('file-request-received', ged.GUI1, self._on_file_request), ('file-request-sent', ged.GUI1, self._on_event), ('our-show', ged.GUI1, self._on_our_show), ('signed-in', ged.GUI1, self._on_signed_in), @@ -178,11 +164,11 @@ def _prepare_window(self) -> None: app.settings.get('trayicon') != 'always'): self.show_all() - def _on_account_enabled(self, event: AccountEnabled) -> None: + def _on_account_enabled(self, event: events.AccountEnabled) -> None: self._account_side_bar.add_account(event.account) self._main_stack.add_account_page(event.account) - def _on_account_disabled(self, event: AccountDisabled) -> None: + def _on_account_disabled(self, event: events.AccountDisabled) -> None: workspace_id = self._workspace_side_bar.get_first_workspace() self.activate_workspace(workspace_id) self._account_side_bar.remove_account(event.account) @@ -190,24 +176,26 @@ def _on_account_disabled(self, event: AccountDisabled) -> None: self._main_stack.remove_chats_for_account(event.account) @staticmethod - def _on_our_show(event: ShowChanged) -> None: + def _on_our_show(event: events.ShowChanged) -> None: if event.show == 'offline': app.app.set_account_actions_state(event.account) app.app.update_app_actions_state() @staticmethod - def _on_signed_in(event: SignedIn) -> None: + def _on_signed_in(event: events.SignedIn) -> None: app.app.set_account_actions_state(event.account, True) app.app.update_app_actions_state() - def _on_allow_gajim_update(self, event: AllowGajimUpdateCheck) -> None: + def _on_allow_gajim_update(self, + event: events.AllowGajimUpdateCheck) -> None: self.add_app_message(event.name) - def _on_gajim_update_available(self, event: GajimUpdateAvailable) -> None: + def _on_gajim_update_available(self, + event: events.GajimUpdateAvailable) -> None: self.add_app_message(event.name, event.version) @staticmethod - def _on_roster_item_exchange(event: RosterItemExchangeEvent) -> None: + def _on_roster_item_exchange(event: events.RosterItemExchangeEvent) -> None: open_window('RosterItemExchange', account=event.client.account, action=event.action, @@ -215,7 +203,7 @@ def _on_roster_item_exchange(event: RosterItemExchangeEvent) -> None: jid_from=event.jid) @staticmethod - def _on_plain_connection(event: PlainConnection) -> None: + def _on_plain_connection(event: events.PlainConnection) -> None: ConfirmationDialog( _('Insecure Connection'), _('Insecure Connection'), @@ -233,11 +221,11 @@ def _on_plain_connection(event: PlainConnection) -> None: callback=event.connect)]).show() @staticmethod - def _on_password_required(event: PasswordRequired) -> None: + def _on_password_required(event: events.PasswordRequired) -> None: open_window('PasswordDialog', event=event) @staticmethod - def _on_http_auth(event: HttpAuth) -> None: + def _on_http_auth(event: events.HttpAuth) -> None: def _response(answer: str) -> None: event.client.get_module('HTTPAuth').build_http_auth_answer( event.stanza, answer) @@ -267,7 +255,7 @@ def _response(answer: str) -> None: callback=_response, args=['yes'])]).show() - def _on_muc_added(self, event: MucAdded) -> None: + def _on_muc_added(self, event: events.MucAdded) -> None: if self.chat_exists(event.account, event.jid): return @@ -523,7 +511,7 @@ def get_chat_list(self, workspace_id: str) -> ChatList: def _add_group_chat(self, _action: Gio.SimpleAction, - param: Optional[GLib.Variant]) -> None: + param: GLib.Variant) -> None: account, jid, select = param.unpack() self.add_group_chat(account, JID.from_string(jid), select) @@ -755,35 +743,41 @@ def _load_chats(self) -> None: self._set_startup_finished() - def _on_event(self, event: ApplicationEvent) -> None: - if event.name == 'update-roster-avatar': + def _on_event(self, event: events.MainEventT) -> None: + if not self.chat_exists(event.account, event.jid): return + self._main_stack.process_event(event) + + def _on_message_received(self, event: events.MessageReceived) -> None: if not self.chat_exists(event.account, event.jid): - if event.name == 'message-received': - if not event.properties.body: - # Don’t open control on chatstate etc. - return - if event.properties.is_muc_pm: - self.add_private_chat(event.account, - event.properties.jid) - else: - jid = event.properties.jid.new_as_bare() - self.add_chat(event.account, jid, 'contact') - elif event.name == 'jingle-request-received': - content_types = [] - for item in event.contents: - content_types.append(item.media) - if 'audio' in content_types or 'video' in content_types: - # AV Call received, open chat control - self.add_chat(event.account, event.jid, 'contact') - elif event.name == 'file-request-received': - # Jingle file transfer, open chat control - self.add_chat(event.account, event.jid, 'contact') - else: - # No chat is open, dont handle any gui events + if not event.properties.body: + # Don’t open control on chatstate etc. return + if event.properties.is_muc_pm: + self.add_private_chat(event.account, + event.properties.jid) + + else: + jid = event.properties.jid.new_as_bare() + self.add_chat(event.account, jid, 'contact') + + self._main_stack.process_event(event) + + def _on_jingle_request(self, event: events.JingleRequestReceived) -> None: + if not self.chat_exists(event.account, event.jid): + for item in event.contents: + if item.media in ('audio', 'video'): + self.add_chat(event.account, event.jid, 'contact') + break + + self._main_stack.process_event(event) + + def _on_file_request(self, event: events.FileRequestReceivedEvent) -> None: + if not self.chat_exists(event.account, event.jid): + self.add_chat(event.account, event.jid, 'contact') + self._main_stack.process_event(event) def quit(self) -> None: @@ -807,8 +801,7 @@ def on_continue2(message: Optional[str]) -> None: app.app.start_shutdown(message=message) return # check if there is an active file transfer - files_props = app.interface.instances['file_transfers'].\ - files_props + files_props = app.interface.instances['file_transfers'].files_props transfer_active = False for x in files_props: for y in files_props[x]: ===================================== gajim/gui_interface.py ===================================== @@ -118,7 +118,7 @@ def __init__(self): self._create_core_handlers_list() self._register_core_handlers() - self.instances = {} + self.instances: dict[str, Any] = {} for acc in app.connections: self.instances[acc] = { @@ -126,7 +126,6 @@ def __init__(self): 'disco': {} } app.automatic_rooms[acc] = {} - app.newly_added[acc] = [] app.to_be_removed[acc] = [] app.nicks[acc] = app.settings.get_account_setting(acc, 'name') @@ -531,7 +530,6 @@ def enable_account(self, account: str) -> None: } app.automatic_rooms[account] = {} - app.newly_added[account] = [] app.to_be_removed[account] = [] app.nicks[account] = app.settings.get_account_setting(account, 'name') app.settings.set_account_setting(account, 'active', True) @@ -566,7 +564,6 @@ def disable_account(self, account: str) -> None: del app.nicks[account] del app.automatic_rooms[account] del app.to_be_removed[account] - del app.newly_added[account] def remove_account(self, account: str) -> None: if app.settings.get_account_setting(account, 'active'): ===================================== pyrightconfig.json ===================================== @@ -60,6 +60,7 @@ "gajim/gtk/groupchat_nick.py", "gajim/gtk/groupchat_settings.py", "gajim/gtk/groupchat_state.py", + "gajim/gtk/main.py", "gajim/gtk/main_stack.py", "gajim/gtk/manage_sounds.py", "gajim/gtk/notification.py", View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/e797ae75677f0c2d8389dab1d0121c2…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/e797ae75677f0c2d8389dab1d0121c2…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: Groupchat: Remove rename page
by Daniel Brötzmann (@wurstsalat)
23 Jan '22
23 Jan '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 298a6900 by wurstsalat at 2022-01-23T19:06:13+01:00 Groupchat: Remove rename page - - - - - e797ae75 by wurstsalat at 2022-01-23T19:25:36+01:00 Menus: Unify single and group chat menu - - - - - 3 changed files: - gajim/data/gui/groupchat_control.ui - gajim/gtk/controls/groupchat.py - gajim/gtk/menus.py Changes: ===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -1748,112 +1748,7 @@ </packing> </child> <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <child> - <!-- n-columns=1 n-rows=3 --> - <object class="GtkGrid"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="row-spacing">12</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">Rename This Chat</property> - <property name="xalign">0</property> - <style> - <class name="bold16"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="name_entry"> - <property name="width-request">200</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="activates-default">True</property> - <property name="caps-lock-warning">False</property> - <property name="secondary-icon-name">face-smile-symbolic</property> - <property name="secondary-icon-tooltip-text" translatable="yes">Insert Emoji</property> - <property name="secondary-icon-tooltip-markup" translatable="yes">Insert Emoji</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="homogeneous">True</property> - <child> - <object class="GtkButton"> - <property name="label" translatable="yes">_Cancel</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="halign">start</property> - <property name="valign">start</property> - <property name="use-underline">True</property> - <signal name="clicked" handler="_on_page_cancel_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="rename_button"> - <property name="label" translatable="yes">_Rename</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="can-default">True</property> - <property name="receives-default">True</property> - <property name="halign">end</property> - <property name="valign">start</property> - <property name="use-underline">True</property> - <signal name="clicked" handler="_on_rename_clicked" swapped="no"/> - <style> - <class name="suggested-action"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">2</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="name">rename</property> - <property name="position">10</property> - </packing> + <placeholder/> </child> <child> <object class="GtkBox"> @@ -1934,9 +1829,6 @@ <property name="position">11</property> </packing> </child> - <child> - <placeholder/> - </child> <child> <object class="GtkBox"> <property name="visible">True</property> @@ -2148,7 +2040,7 @@ </object> <packing> <property name="name">muc-manage</property> - <property name="position">13</property> + <property name="position">12</property> </packing> </child> <child> @@ -2257,7 +2149,7 @@ </object> <packing> <property name="name">avatar-selector</property> - <property name="position">14</property> + <property name="position">13</property> </packing> </child> </object> ===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -286,7 +286,6 @@ def add_actions(self) -> None: super().add_actions() actions = [ ('groupchat-manage-', None, self._on_groupchat_manage), - ('rename-groupchat-', None, self._on_rename_groupchat), ('change-nickname-', None, self._on_change_nick), ('destroy-', None, self._on_destroy_room), ('configure-', None, self._on_configure_room), @@ -385,7 +384,6 @@ def remove_actions(self) -> None: super().remove_actions() actions = [ 'groupchat-manage-', - 'rename-groupchat-', 'change-nickname-', 'destroy-', 'configure-', @@ -1578,8 +1576,6 @@ def focus(self) -> None: self.xml.password_entry.grab_focus_without_selecting() elif page_name == 'nickname': self.xml.nickname_entry.grab_focus_without_selecting() - elif page_name == 'rename': - self.xml.name_entry.grab_focus_without_selecting() elif page_name == 'subject': self.xml.subject_textview.grab_focus() elif page_name == 'captcha': @@ -1645,23 +1641,6 @@ def _on_nickname_change_clicked(self, _button: Gtk.Button) -> None: self._client.get_module('MUC').change_nick(self.room_jid, new_nick) self._show_page('groupchat') - def _on_rename_groupchat(self, - _action: Gio.SimpleAction, - _param: Optional[GLib.Variant] - ) -> None: - if self._get_current_page() != 'groupchat': - return - self.xml.name_entry.set_text(self.contact.name) - self.xml.name_entry.grab_focus() - self.xml.rename_button.grab_default() - self._show_page('rename') - - def _on_rename_clicked(self, _button: Gtk.Button) -> None: - new_name = self.xml.name_entry.get_text() - self._client.get_module('Bookmarks').modify( - self.room_jid, name=new_name) - self._show_page('groupchat') - def _on_manage_save_clicked(self, _button: Gtk.Button) -> None: if self._room_config_form is not None: name = self.xml.muc_name_entry.get_text() ===================================== gajim/gtk/menus.py ===================================== @@ -64,35 +64,36 @@ def get_singlechat_menu(control_id: str, is_self_contact = jid.bare == client.get_own_jid().bare contact = client.get_module('Contacts').get_contact(jid) - singlechat_menu: list[tuple[str, Any]] = [ + self_contact_menu: list[tuple[str, Any]] = [ + ('profile', _('Profile')), (_('Send File'), [ ('win.send-file-httpupload-', _('Upload File…')), ('win.send-file-jingle-', _('Send File Directly…')) - ]) + ]), + ('app.remove-history', _('Remove History…')), + ('win.search-history', _('Search…')) ] - additional_menu: list[tuple[str, Any]] = [ + singlechat_menu: list[tuple[str, Any]] = [ + ('win.information-', _('Details')), ('win.send-marker-', _('Send Read Markers')), (_('Send Chatstate'), ['chatstate']), ('win.block-contact-', _('Block Contact…')), + (_('Send File'), [ + ('win.send-file-httpupload-', _('Upload File…')), + ('win.send-file-jingle-', _('Send File Directly…')) + ]), ('win.start-call-', _('Start Call…')), - ('win.information-', _('Information')), - ('app.remove-history', _('Remove History…')) + ('app.remove-history', _('Remove History…')), + ('win.search-history', _('Search…')) ] if not contact.is_in_roster: if (type_.is_chat or (type_.is_privatechat and contact.real_jid is not None)): - additional_menu.append( + singlechat_menu.append( ('win.add-to-roster-', _('Add to Contact List…'))) - if is_self_contact: - singlechat_menu.append(('profile', _('Profile'))) - else: - singlechat_menu.extend(additional_menu) - - singlechat_menu.append(('win.search-history', _('Search…'))) - def build_chatstate_menu() -> Gio.Menu: menu = Gio.Menu() entries = [ @@ -112,7 +113,7 @@ def build_menu(preset: list[tuple[str, Any]]): for item in preset: if isinstance(item[1], str): action_name, label = item - if action_name == 'win.send-marker-' and type_ == 'pm': + if action_name == 'win.send-marker-' and type_.is_privatechat: continue if action_name == 'win.search-history': @@ -142,6 +143,9 @@ def build_menu(preset: list[tuple[str, Any]]): menu.append_submenu(label, submenu) return menu + if is_self_contact: + return build_menu(self_contact_menu) + return build_menu(singlechat_menu) @@ -152,12 +156,11 @@ def get_groupchat_menu(control_id: str, account: str, jid: JID) -> Gio.Menu: menulist: MenuItemListT = [ (_('Details'), f'win.groupchat-details-{control_id}', None), (_('Manage…'), f'win.groupchat-manage-{control_id}', None), - (_('Rename Chat…'), f'win.rename-groupchat-{control_id}', None), (_('Change Nickname…'), f'win.change-nickname-{control_id}', None), (_('Request Voice'), f'win.request-voice-{control_id}', None), (_('Execute Command…'), f'win.execute-command-{control_id}', '""'), - (_('Search…'), 'win.search-history', None), - (_('Remove History…'), 'app.remove-history', params) + (_('Remove History…'), 'app.remove-history', params), + (_('Search…'), 'win.search-history', None) ] return make_menu(menulist) @@ -408,7 +411,7 @@ def get_roster_menu(account: str, jid: str, gateway: bool = False) -> Gio.Menu: value = f'"{jid}"' menuitems: MenuItemListT = [ - (_('Information'), f'win.contact-info-{account}', value), + (_('Details'), f'win.contact-info-{account}', value), (_('Execute Command…'), f'win.execute-command-{account}', value), (block_label, f'win.block-contact-{account}', value), (_('Remove…'), f'win.remove-contact-{account}', value), @@ -429,7 +432,7 @@ def get_subscription_menu(account: str, jid: JID) -> Gio.Menu: value = f'"{jid}"' menuitems: MenuItemListT = [ (_('Start Chat'), 'win.add-chat', params), - (_('Information'), f'win.contact-info-{account}', value), + (_('Details'), f'win.contact-info-{account}', value), (_('Block'), f'win.subscription-block-{account}', value), (_('Report'), f'win.subscription-report-{account}', value), (_('Deny'), f'win.subscription-deny-{account}', value), @@ -588,7 +591,7 @@ def get_groupchat_roster_menu(account: str, value = f'"{contact.name}"' general_items: MenuItemListT = [ - (_('Information'), f'win.contact-information-{control_id}', value), + (_('Details'), f'win.contact-information-{control_id}', value), (_('Execute Command…'), f'win.execute-command-{control_id}', value), ] View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/59439c83b3b7e5136a3508328f037bc…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/59439c83b3b7e5136a3508328f037bc…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] Add ConfirmationDialog for removing chat history
by Daniel Brötzmann (@wurstsalat)
23 Jan '22
23 Jan '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 59439c83 by wurstsalat at 2022-01-23T14:36:11+01:00 Add ConfirmationDialog for removing chat history - - - - - 2 changed files: - gajim/gtk/application.py - gajim/gtk/menus.py Changes: ===================================== gajim/gtk/application.py ===================================== @@ -74,6 +74,8 @@ from gajim.gui.about import AboutDialog from gajim.gui.avatar import AvatarStorage from gajim.gui.builder import get_builder +from gajim.gui.dialogs import DialogButton +from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.dialogs import ShortcutsWindow from gajim.gui.discovery import ServiceDiscoveryWindow from gajim.gui.util import get_app_window @@ -803,15 +805,23 @@ def _on_open_chat_action(_action: Gio.SimpleAction, def _on_remove_history_action(_action: Gio.SimpleAction, params: structs.RemoveHistoryActionParams ) -> None: - - if params.jid is not None: - app.storage.archive.remove_history(params.account, params.jid) - control = app.window.get_control(params.account, params.jid) - if control is not None: - control.reset_view() - else: - for control in app.window.get_controls(params.account): - control.reset_view() + def _remove() -> None: + if params.jid is not None: + app.storage.archive.remove_history(params.account, params.jid) + control = app.window.get_control(params.account, params.jid) + if control is not None: + control.reset_view() + else: + for control in app.window.get_controls(params.account): + control.reset_view() + ConfirmationDialog( + _('Remove Chat History'), + _('Remove Chat History?'), + _('Do you really want to remove your chat history for this chat?'), + [DialogButton.make('Cancel'), + DialogButton.make('Remove', + callback=_remove)], + transient_for=app.window).show() @staticmethod @structs.actionfunction ===================================== gajim/gtk/menus.py ===================================== @@ -77,7 +77,7 @@ def get_singlechat_menu(control_id: str, ('win.block-contact-', _('Block Contact…')), ('win.start-call-', _('Start Call…')), ('win.information-', _('Information')), - ('app.remove-history', _('Remove History')) + ('app.remove-history', _('Remove History…')) ] if not contact.is_in_roster: @@ -157,7 +157,7 @@ def get_groupchat_menu(control_id: str, account: str, jid: JID) -> Gio.Menu: (_('Request Voice'), f'win.request-voice-{control_id}', None), (_('Execute Command…'), f'win.execute-command-{control_id}', '""'), (_('Search…'), 'win.search-history', None), - (_('Remove History'), 'app.remove-history', params) + (_('Remove History…'), 'app.remove-history', params) ] return make_menu(menulist) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/59439c83b3b7e5136a3508328f037bce…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/59439c83b3b7e5136a3508328f037bce…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] GroupchatDetails: Styling
by Daniel Brötzmann (@wurstsalat)
23 Jan '22
23 Jan '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 7e95d2e3 by wurstsalat at 2022-01-23T14:17:49+01:00 GroupchatDetails: Styling - - - - - 3 changed files: - + gajim/data/gui/groupchat_details.ui - gajim/gtk/builder.pyi - gajim/gtk/groupchat_details.py Changes: ===================================== gajim/data/gui/groupchat_details.ui ===================================== @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface> + <requires lib="gtk+" version="3.24"/> + <!-- n-columns=2 n-rows=1 --> + <object class="GtkGrid" id="main_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="GtkBox"> + <property name="width-request">570</property> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkRevealer" id="header_revealer"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="transition-duration">200</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="spacing">12</property> + <child> + <object class="GtkImage" id="header_image"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">missing-image</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="name_entry"> + <property name="name">ContactNameEntry</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can-focus">True</property> + <property name="valign">center</property> + <property name="activates-default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="edit_name_button"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">Edit Name…</property> + <property name="valign">center</property> + <signal name="toggled" handler="_on_edit_name_toggled" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">document-edit-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <style> + <class name="stack-header"/> + </style> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkStack" id="main_stack"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="transition-type">crossfade</property> + <child> + <object class="GtkBox" id="info_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + <style> + <class name="padding-18"/> + </style> + </object> + <packing> + <property name="name">information</property> + <property name="title" translatable="yes">Information</property> + <property name="icon-name">user-info-symbolic</property> + </packing> + </child> + <child> + <object class="GtkBox" id="settings_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + <style> + <class name="padding-18"/> + </style> + </object> + <packing> + <property name="name">settings</property> + <property name="title" translatable="yes">Settings</property> + <property name="icon-name">document-properties-symbolic</property> + <property name="position">1</property> + </packing> + </child> + <style> + <class name="stack-border"/> + </style> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> +</interface> ===================================== gajim/gtk/builder.pyi ===================================== @@ -475,6 +475,17 @@ class GroupchatCreationBuilder(Builder): create_button: Gtk.Button +class GroupchatDetailsBuilder(Builder): + main_grid: Gtk.Grid + header_revealer: Gtk.Revealer + header_image: Gtk.Image + name_entry: Gtk.Entry + edit_name_button: Gtk.ToggleButton + main_stack: Gtk.Stack + info_box: Gtk.Box + settings_box: Gtk.Box + + class GroupchatInfoScrolledBuilder(Builder): info_grid: Gtk.Grid address_label: Gtk.Label @@ -983,6 +994,8 @@ def get_builder(file_name: Literal['groupchat_control.ui'], widgets: list[str] = @overload def get_builder(file_name: Literal['groupchat_creation.ui'], widgets: list[str] = ...) -> GroupchatCreationBuilder: ... @overload +def get_builder(file_name: Literal['groupchat_details.ui'], widgets: list[str] = ...) -> GroupchatDetailsBuilder: ... +@overload def get_builder(file_name: Literal['groupchat_info_scrolled.ui'], widgets: list[str] = ...) -> GroupchatInfoScrolledBuilder: ... @overload def get_builder(file_name: Literal['groupchat_inviter.ui'], widgets: list[str] = ...) -> GroupchatInviterBuilder: ... ===================================== gajim/gtk/groupchat_details.py ===================================== @@ -14,20 +14,28 @@ from __future__ import annotations +from typing import Optional + from gi.repository import Gdk +from gi.repository import GObject from gi.repository import Gtk from gajim.common import app +from gajim.common.const import AvatarSize from gajim.common.i18n import _ from gajim.common.modules.contacts import GroupchatContact +from .builder import get_builder from .groupchat_info import GroupChatInfoScrolled from .groupchat_settings import GroupChatSettings from .sidebar_switcher import SideBarSwitcher class GroupchatDetails(Gtk.ApplicationWindow): - def __init__(self, contact: GroupchatContact) -> None: + def __init__(self, + contact: GroupchatContact, + page: Optional[str] = None + ) -> None: Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) @@ -38,27 +46,55 @@ def __init__(self, contact: GroupchatContact) -> None: self.set_title(_('Groupchat Details')) self.account = contact.account + self._client = app.get_client(contact.account) self._contact = contact - main_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) - self._stack = Gtk.Stack() - self._side_bar_switcher = SideBarSwitcher() + self._ui = get_builder('groupchat_details.ui') + self._ui.connect_signals(self) - main_box.add(self._side_bar_switcher) - main_box.add(self._stack) + self._switcher = SideBarSwitcher() + self._switcher.set_stack(self._ui.main_stack, rows_visible=False) + self._ui.main_grid.attach(self._switcher, 0, 0, 1, 1) + self._ui.main_stack.connect('notify::visible-child-name', + self._on_stack_child_changed) + self.add(self._ui.main_grid) self._add_groupchat_info() self._add_groupchat_settings() - self._side_bar_switcher.set_stack(self._stack) + self._load_avatar() + self._ui.name_entry.set_text(contact.name) - self.add(main_box) + if page is not None: + self._switcher.set_row(page) self.connect('key-press-event', self._on_key_press) self.connect('destroy', self._on_destroy) self.show_all() + def _on_stack_child_changed(self, + _widget: Gtk.Stack, + _pspec: GObject.ParamSpec) -> None: + + name = self._ui.main_stack.get_visible_child_name() + self._ui.header_revealer.set_reveal_child(name != 'information') + + def _on_edit_name_toggled(self, widget: Gtk.ToggleButton) -> None: + active = widget.get_active() + self._ui.name_entry.set_sensitive(active) + if active: + self._ui.name_entry.grab_focus() + + name = self._ui.name_entry.get_text() + self._client.get_module('Bookmarks').modify( + self._contact.jid, name=name) + + def _load_avatar(self) -> None: + scale = self.get_scale_factor() + surface = self._contact.get_avatar(AvatarSize.VCARD_HEADER, scale) + self._ui.header_image.set_from_surface(surface) + def _add_groupchat_info(self) -> None: groupchat_info = GroupChatInfoScrolled(self._contact.account, width=600) groupchat_info.set_halign(Gtk.Align.FILL) @@ -66,17 +102,19 @@ def _add_groupchat_info(self) -> None: assert disco_info is not None groupchat_info.set_from_disco_info(disco_info) groupchat_info.set_subject(self._contact.subject) - - self._stack.add_titled(groupchat_info, 'info', _('Information')) + self._ui.info_box.add(groupchat_info) + self._switcher.set_row_visible('information', True) def _add_groupchat_settings(self) -> None: scrolled_window = Gtk.ScrolledWindow() + scrolled_window.set_vexpand(True) scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) settings_box = GroupChatSettings(self.account, self._contact.jid) scrolled_window.add(settings_box) - self._stack.add_titled(scrolled_window, 'settings', _('Settings')) + self._ui.settings_box.add(scrolled_window) + self._switcher.set_row_visible('settings', True) def _on_key_press(self, _widget: GroupchatDetails, View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/7e95d2e31b1fe0bf2866bdbfc22bcaf1…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/7e95d2e31b1fe0bf2866bdbfc22bcaf1…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: Remove dead code
by Philipp Hörist (@lovetox)
23 Jan '22
23 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 10e4f811 by lovetox at 2022-01-23T13:04:20+01:00 Remove dead code Code regarding blocking signed in notifications, because we don’t show these notifications anymore - - - - - c208c063 by lovetox at 2022-01-23T13:10:05+01:00 Interface: Handle muc-added event in MainWindow - - - - - 5 changed files: - gajim/common/app.py - gajim/common/events.py - gajim/common/modules/muc.py - gajim/gtk/main.py - gajim/gui_interface.py Changes: ===================================== gajim/common/app.py ===================================== @@ -104,13 +104,6 @@ def __init__(self): # list of our nick names in each account nicks: dict[str, str] = {} -# should we block 'contact signed in' notifications for this account? -# this is only for the first 30 seconds after we change our show -# to something else than offline -# can also contain account/transport_jid to block notifications for contacts -# from this transport -block_signed_in_notifications: dict[str, bool] = {} - proxy65_manager = None cert_store = cast('CertificateStore', None) ===================================== gajim/common/events.py ===================================== @@ -504,7 +504,7 @@ class JingleErrorReceived(JingleEvent): class MucAdded(ApplicationEvent): name: str = field(init=False, default='muc-added') account: str - jid: str + jid: JID @dataclass ===================================== gajim/common/modules/muc.py ===================================== @@ -24,6 +24,7 @@ from nbxmpp.const import InviteType from nbxmpp.const import PresenceType from nbxmpp.const import StatusCode +from nbxmpp.protocol import JID from nbxmpp.structs import StanzaHandler from nbxmpp.errors import StanzaError @@ -250,8 +251,9 @@ def create(self, jid, config): self._create(muc_data) self._push_muc_added_event(jid) - def _push_muc_added_event(self, jid): - app.ged.raise_event(MucAdded(account=self._account, jid=jid)) + def _push_muc_added_event(self, jid: str) -> None: + app.ged.raise_event(MucAdded(account=self._account, + jid=JID.from_string(jid))) def _on_disco_result(self, task): try: ===================================== gajim/gtk/main.py ===================================== @@ -32,6 +32,7 @@ from gajim.common import ged from gajim.common.const import Direction from gajim.common.events import ApplicationEvent +from gajim.common.events import MucAdded from gajim.common.events import HttpAuth from gajim.common.events import PasswordRequired from gajim.common.events import PlainConnection @@ -136,6 +137,7 @@ def __init__(self) -> None: ('plain-connection', ged.GUI1, self._on_plain_connection), ('password-required', ged.GUI1, self._on_password_required), ('http-auth', ged.GUI1, self._on_http_auth), + ('muc-added', ged.GUI1, self._on_muc_added), ]) self._check_for_account() @@ -265,6 +267,12 @@ def _response(answer: str) -> None: callback=_response, args=['yes'])]).show() + def _on_muc_added(self, event: MucAdded) -> None: + if self.chat_exists(event.account, event.jid): + return + + self.add_group_chat(event.account, event.jid) + def _add_actions(self) -> None: actions = [ ('add-workspace', 's', self._add_workspace), ===================================== gajim/gui_interface.py ===================================== @@ -67,7 +67,6 @@ from gajim.common.events import FileHashError from gajim.common.events import FileProgress from gajim.common.events import FileError -from gajim.common.events import MucAdded from gajim.common.helpers import ask_for_status_message from gajim.common.structs import OutgoingMessage from gajim.common.i18n import _ @@ -119,10 +118,6 @@ def __init__(self): self._create_core_handlers_list() self._register_core_handlers() - app.ged.register_event_handler('muc-added', - ged.CORE, - self._on_muc_added) - self.instances = {} for acc in app.connections: @@ -134,7 +129,6 @@ def __init__(self): app.newly_added[acc] = [] app.to_be_removed[acc] = [] app.nicks[acc] = app.settings.get_account_setting(acc, 'name') - app.block_signed_in_notifications[acc] = True def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long @@ -142,7 +136,6 @@ def _create_core_handlers_list(self) -> None: 'iq-error-received': [self.handle_event_iq_error], 'signed-in': [self.handle_event_signed_in], 'presence-received': [self.handle_event_presence], - 'our-show': [self.handle_event_status], 'message-sent': [self.handle_event_msgsent], 'message-not-sent': [self.handle_event_msgnotsent], 'read-state-sync': [self.handle_event_read_state_sync], @@ -183,7 +176,6 @@ def handle_event_signed_in(event): # Add our own JID into the DB app.storage.archive.insert_jid(event.conn.get_own_jid().bare) account = event.conn.name - app.block_signed_in_notifications[account] = True pep_supported = event.conn.get_module('PEP').supported @@ -200,48 +192,13 @@ def handle_event_signed_in(event): app.window.show_account_page(account) def handle_event_presence(self, event): - # TODO: - # 'NOTIFY' (account, (jid, status, status message, resource, - # priority, timestamp)) - # - # Contact changed show account = event.conn.name jid = event.jid - if app.jid_is_transport(jid): - # It must be an agent - - # transport just signed in/out, don't show - # popup notifications for 30s - account_jid = account + '/' + jid - app.block_signed_in_notifications[account_jid] = True - GLib.timeout_add_seconds(30, self._unblock_signed_in_notifications, - account_jid) - ctrl = app.window.get_control(account, jid) if ctrl and ctrl.session and len(event.contact_list) > 1: ctrl.remove_session(ctrl.session) - def handle_event_status(self, event): - if event.show in ('offline', 'error'): - # TODO: Close all account windows - pass - - 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, - event.account) - - @staticmethod - def _unblock_signed_in_notifications(account: str) -> None: - app.block_signed_in_notifications[account] = False - @staticmethod def handle_event_msgsent(event): if not event.play_sound: @@ -506,13 +463,6 @@ def start_chat_from_jid(account: str, # TODO: handle message arg in StartChat app.app.activate_action('start-chat', GLib.Variant('s', str(jid))) - @staticmethod - def _on_muc_added(event: MucAdded) -> None: - if app.window.chat_exists(event.account, JID.from_string(event.jid)): - return - - app.window.add_group_chat(event.account, JID.from_string(event.jid)) - @staticmethod def create_account(account: str, username: str, @@ -574,9 +524,6 @@ def enable_account(self, account: str) -> None: app.plugin_manager.register_modules_for_account( app.connections[account]) - app.ged.register_event_handler( - 'muc-added', ged.CORE, self._on_muc_added) - # update variables self.instances[account] = { 'infos': {}, @@ -586,10 +533,7 @@ def enable_account(self, account: str) -> None: app.automatic_rooms[account] = {} app.newly_added[account] = [] app.to_be_removed[account] = [] - app.nicks[account] = app.settings.get_account_setting(account, - 'name') - app.block_signed_in_notifications[account] = True - + app.nicks[account] = app.settings.get_account_setting(account, 'name') app.settings.set_account_setting(account, 'active', True) build_accounts_menu() app.app.update_app_actions_state() @@ -620,7 +564,6 @@ def disable_account(self, account: str) -> None: del app.connections[account] del self.instances[account] del app.nicks[account] - del app.block_signed_in_notifications[account] del app.automatic_rooms[account] del app.to_be_removed[account] del app.newly_added[account] View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0ca879b48b5e5888242cd54405cdbe5…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0ca879b48b5e5888242cd54405cdbe5…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 3 commits: Client: Fix raising PasswordRequired Event
by Philipp Hörist (@lovetox)
23 Jan '22
23 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: eb869c38 by lovetox at 2022-01-23T12:48:37+01:00 Client: Fix raising PasswordRequired Event - - - - - c80c9c38 by lovetox at 2022-01-23T12:50:48+01:00 Interface: Handle http-auth event in MainWindow - - - - - 0ca879b4 by lovetox at 2022-01-23T12:57:04+01:00 HTTPAuth: Simplify code - - - - - 5 changed files: - gajim/common/client.py - gajim/common/events.py - gajim/common/modules/http_auth.py - gajim/gtk/main.py - gajim/gui_interface.py Changes: ===================================== gajim/common/client.py ===================================== @@ -293,7 +293,7 @@ def _on_password(password: str) -> None: self._client.set_password(password) self._prepare_for_connect() - app.ged.raise_event(PasswordRequired(conn=self, + app.ged.raise_event(PasswordRequired(client=self, on_password=_on_password)) app.ged.raise_event( ===================================== gajim/common/events.py ===================================== @@ -24,6 +24,7 @@ from dataclasses import field from nbxmpp.protocol import JID +from nbxmpp.structs import HTTPAuthData from nbxmpp.structs import RosterItem from nbxmpp.structs import TuneData from nbxmpp.const import InviteType @@ -274,13 +275,10 @@ class IqErrorReceived(ApplicationEvent): @dataclass -class HttpAuthReceived(ApplicationEvent): - name: str = field(init=False, default='http-auth-received') - conn: 'Client' - iq_id: str - method: str - url: str - msg: str +class HttpAuth(ApplicationEvent): + name: str = field(init=False, default='http-auth') + client: 'Client' + data: HTTPAuthData stanza: Any ===================================== gajim/common/modules/http_auth.py ===================================== @@ -19,7 +19,7 @@ from nbxmpp.namespaces import Namespace from gajim.common import app -from gajim.common.events import HttpAuthReceived +from gajim.common.events import HttpAuth from gajim.common.modules.base import BaseModule @@ -51,12 +51,9 @@ def _http_auth(self, _con, stanza, properties): raise nbxmpp.NodeProcessed app.ged.raise_event( - HttpAuthReceived(conn=self._con, - iq_id=properties.http_auth.id, - method=properties.http_auth.method, - url=properties.http_auth.url, - msg=properties.http_auth.body, - stanza=stanza)) + HttpAuth(client=self._con, + data=properties.http_auth, + stanza=stanza)) raise nbxmpp.NodeProcessed def build_http_auth_answer(self, stanza, answer): ===================================== gajim/gtk/main.py ===================================== @@ -32,6 +32,7 @@ from gajim.common import ged from gajim.common.const import Direction from gajim.common.events import ApplicationEvent +from gajim.common.events import HttpAuth from gajim.common.events import PasswordRequired from gajim.common.events import PlainConnection from gajim.common.events import RosterItemExchangeEvent @@ -134,6 +135,7 @@ def __init__(self) -> None: ('roster-item-exchange', ged.GUI1, self._on_roster_item_exchange), ('plain-connection', ged.GUI1, self._on_plain_connection), ('password-required', ged.GUI1, self._on_password_required), + ('http-auth', ged.GUI1, self._on_http_auth), ]) self._check_for_account() @@ -232,6 +234,37 @@ def _on_plain_connection(event: PlainConnection) -> None: def _on_password_required(event: PasswordRequired) -> None: open_window('PasswordDialog', event=event) + @staticmethod + def _on_http_auth(event: HttpAuth) -> None: + def _response(answer: str) -> None: + event.client.get_module('HTTPAuth').build_http_auth_answer( + event.stanza, answer) + + account = event.client.account + message = _('HTTP (%(method)s) Authorization ' + 'for %(url)s (ID: %(id)s)') % { + 'method': event.data.method, + 'url': event.data.url, + 'id': event.data.id} + sec_msg = _('Do you accept this request?') + if app.get_number_of_connected_accounts() > 1: + sec_msg = _('Do you accept this request (account: %s)?') % account + if event.data.body: + sec_msg = event.data.body + '\n' + sec_msg + message = message + '\n' + sec_msg + + ConfirmationDialog( + _('Authorization Request'), + _('HTTP Authorization Request'), + message, + [DialogButton.make('Cancel', + text=_('_No'), + callback=_response, + args=['no']), + DialogButton.make('Accept', + callback=_response, + args=['yes'])]).show() + def _add_actions(self) -> None: actions = [ ('add-workspace', 's', self._add_workspace), ===================================== gajim/gui_interface.py ===================================== @@ -81,9 +81,7 @@ from gajim.common.modules.contacts import BareContact from gajim.common.modules.httpupload import HTTPFileTransfer -from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ErrorDialog -from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.filechoosers import FileChooserDialog from gajim.gui.filetransfer import FileTransfersWindow from gajim.gui.menus import build_accounts_menu @@ -142,7 +140,6 @@ def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long self.handlers = { 'iq-error-received': [self.handle_event_iq_error], - 'http-auth-received': [self.handle_event_http_auth], 'signed-in': [self.handle_event_signed_in], 'presence-received': [self.handle_event_presence], 'our-show': [self.handle_event_status], @@ -175,38 +172,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_http_auth(event): - # ('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg)) - def _response(answer: str) -> None: - event.conn.get_module('HTTPAuth').build_http_auth_answer( - event.stanza, answer) - - account = event.conn.name - message = _('HTTP (%(method)s) Authorization ' - 'for %(url)s (ID: %(id)s)') % { - 'method': event.method, - 'url': event.url, - 'id': event.iq_id} - sec_msg = _('Do you accept this request?') - if app.get_number_of_connected_accounts() > 1: - sec_msg = _('Do you accept this request (account: %s)?') % account - if event.msg: - sec_msg = event.msg + '\n' + sec_msg - message = message + '\n' + sec_msg - - ConfirmationDialog( - _('Authorization Request'), - _('HTTP Authorization Request'), - message, - [DialogButton.make('Cancel', - text=_('_No'), - callback=_response, - args=['no']), - DialogButton.make('Accept', - callback=_response, - args=['yes'])]).show() - @staticmethod def handle_event_signed_in(event): """ View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/e4189cbc9ed1eccd459ae53701f82b6…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/e4189cbc9ed1eccd459ae53701f82b6…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 4 commits: Interface: Handle plain-connection event in MainWindow
by Philipp Hörist (@lovetox)
23 Jan '22
23 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: e6152d79 by lovetox at 2022-01-23T12:22:32+01:00 Interface: Handle plain-connection event in MainWindow - - - - - aa2f660e by lovetox at 2022-01-23T12:26:47+01:00 Interface: Handle password-required event in MainWindow - - - - - 64e7e766 by lovetox at 2022-01-23T12:32:18+01:00 Remove dead client-cert-passphrase event handling nbxmpp does not support client certificates anymore - - - - - e4189cbc by lovetox at 2022-01-23T12:32:29+01:00 Update pyrightconfig.json - - - - - 5 changed files: - gajim/common/events.py - gajim/gtk/main.py - gajim/gtk/password_dialog.py - gajim/gui_interface.py - pyrightconfig.json Changes: ===================================== gajim/common/events.py ===================================== @@ -81,7 +81,7 @@ class PlainConnection(ApplicationEvent): @dataclass class PasswordRequired(ApplicationEvent): name: str = field(init=False, default='password-required') - conn: 'Client' + client: 'Client' on_password: Callable[..., Any] ===================================== gajim/gtk/main.py ===================================== @@ -32,6 +32,8 @@ from gajim.common import ged from gajim.common.const import Direction from gajim.common.events import ApplicationEvent +from gajim.common.events import PasswordRequired +from gajim.common.events import PlainConnection from gajim.common.events import RosterItemExchangeEvent from gajim.common.events import AllowGajimUpdateCheck from gajim.common.events import GajimUpdateAvailable @@ -130,6 +132,8 @@ def __init__(self) -> None: ('allow-gajim-update-check', ged.GUI1, self._on_allow_gajim_update), ('gajim-update-available', ged.GUI1, self._on_gajim_update_available), ('roster-item-exchange', ged.GUI1, self._on_roster_item_exchange), + ('plain-connection', ged.GUI1, self._on_plain_connection), + ('password-required', ged.GUI1, self._on_password_required), ]) self._check_for_account() @@ -206,6 +210,28 @@ def _on_roster_item_exchange(event: RosterItemExchangeEvent) -> None: exchange_list=event.exchange_items_list, jid_from=event.jid) + @staticmethod + def _on_plain_connection(event: PlainConnection) -> None: + ConfirmationDialog( + _('Insecure Connection'), + _('Insecure Connection'), + _('You are about to connect to the account %(account)s ' + '(%(server)s) using an insecure connection method. This means ' + 'conversations will not be encrypted. Connecting PLAIN is ' + 'strongly discouraged.') % { + 'account': event.account, + 'server': app.get_hostname_from_account(event.account)}, + [DialogButton.make('Cancel', + text=_('_Abort'), + callback=event.abort), + DialogButton.make('Remove', + text=_('_Connect Anyway'), + callback=event.connect)]).show() + + @staticmethod + def _on_password_required(event: PasswordRequired) -> None: + open_window('PasswordDialog', event=event) + def _add_actions(self) -> None: actions = [ ('add-workspace', 's', self._add_workspace), ===================================== gajim/gtk/password_dialog.py ===================================== @@ -29,7 +29,7 @@ class PasswordDialog(Gtk.ApplicationWindow): - def __init__(self, account: str, event: PasswordRequired) -> None: + def __init__(self, event: PasswordRequired) -> None: Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) @@ -42,8 +42,8 @@ def __init__(self, account: str, event: PasswordRequired) -> None: self._ui = get_builder('password_dialog.ui') self.add(self._ui.pass_box) - self.account = account - self._client = app.get_client(account) + self.account = event.client.account + self._client = app.get_client(event.client.account) self._event = event self.connect('key-press-event', self._on_key_press) @@ -62,53 +62,28 @@ def _process_event(self) -> None: account_name = app.settings.get_account_setting( self.account, 'name') - if self._event.name == 'password-required': - self._ui.header.set_text(_('Password Required')) - self._ui.message_label.set_text( - _('Please enter your password for\n' - '%(jid)s\n(Account: %(account)s)') % { - 'jid': own_jid, - 'account': account_name}) - self._ui.save_pass_checkbutton.show() - self._ui.save_pass_checkbutton.set_sensitive( - not app.settings.get('use_keyring') or KEYRING_AVAILABLE) - if not KEYRING_AVAILABLE: - self._ui.keyring_hint.show() - - if self._event.name == 'client-cert-passphrase': - self._ui.header.set_text(_('Certificate Password Required')) - self._ui.message_label.set_text( - _('Please enter your certificate password for ' - '%(jid)s (%(account)s)') % { - 'jid': own_jid, - 'account': account_name}) + self._ui.header.set_text(_('Password Required')) + self._ui.message_label.set_text( + _('Please enter your password for\n' + '%(jid)s\n(Account: %(account)s)') % { + 'jid': own_jid, + 'account': account_name}) + self._ui.save_pass_checkbutton.show() + self._ui.save_pass_checkbutton.set_sensitive( + not app.settings.get('use_keyring') or KEYRING_AVAILABLE) + if not KEYRING_AVAILABLE: + self._ui.keyring_hint.show() def _on_ok(self, _button: Gtk.Button) -> None: password = self._ui.pass_entry.get_text() - if self._event.name == 'password-required': - app.settings.set_account_setting( - self.account, - 'savepass', - self._ui.save_pass_checkbutton.get_active()) - save_password(self.account, password) - self._event.on_password(password) - self.destroy() - - if self._event.name == 'client-cert-passphrase': - self._event.conn.on_client_cert_passphrase( - password, - self._event.con, - self._event.port, - self._event.secure_tuple) - self.destroy() + app.settings.set_account_setting( + self.account, + 'savepass', + self._ui.save_pass_checkbutton.get_active()) + save_password(self.account, password) + self._event.on_password(password) + self.destroy() def _on_cancel(self, _button: Gtk.Button) -> None: - if self._event.name == 'client-cert-passphrase': - self._event.conn.on_client_cert_passphrase( - '', - self._event.con, - self._event.port, - self._event.secure_tuple) - self.destroy() ===================================== gajim/gui_interface.py ===================================== @@ -68,7 +68,6 @@ from gajim.common.events import FileProgress from gajim.common.events import FileError from gajim.common.events import MucAdded -from gajim.common.events import PasswordRequired from gajim.common.helpers import ask_for_status_message from gajim.common.structs import OutgoingMessage from gajim.common.i18n import _ @@ -91,7 +90,6 @@ from gajim.gui.util import get_app_window from gajim.gui.util import get_app_windows from gajim.gui.util import get_color_for_account -from gajim.gui.util import open_window from gajim.gui.types import ControlT log = logging.getLogger('gajim.interface') @@ -144,10 +142,7 @@ def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long self.handlers = { 'iq-error-received': [self.handle_event_iq_error], - 'plain-connection': [self.handle_event_plain_connection], 'http-auth-received': [self.handle_event_http_auth], - 'password-required': [self.handle_event_password_required], - 'client-cert-passphrase': [self.handle_event_client_cert_passphrase], 'signed-in': [self.handle_event_signed_in], 'presence-received': [self.handle_event_presence], 'our-show': [self.handle_event_status], @@ -180,24 +175,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_plain_connection(event): - ConfirmationDialog( - _('Insecure Connection'), - _('Insecure Connection'), - _('You are about to connect to the account %(account)s ' - '(%(server)s) using an insecure connection method. This means ' - 'conversations will not be encrypted. Connecting PLAIN is ' - 'strongly discouraged.') % { - 'account': event.account, - 'server': app.get_hostname_from_account(event.account)}, - [DialogButton.make('Cancel', - text=_('_Abort'), - callback=event.abort), - DialogButton.make('Remove', - text=_('_Connect Anyway'), - callback=event.connect)]).show() - @staticmethod def handle_event_http_auth(event): # ('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg)) @@ -230,14 +207,6 @@ def _response(answer: str) -> None: callback=_response, args=['yes'])]).show() - @staticmethod - def handle_event_client_cert_passphrase(event): - open_window('PasswordDialog', account=event.conn.name, event=event) - - @staticmethod - def handle_event_password_required(event: PasswordRequired) -> None: - open_window('PasswordDialog', account=event.conn.name, event=event) - @staticmethod def handle_event_signed_in(event): """ ===================================== pyrightconfig.json ===================================== @@ -63,6 +63,7 @@ "gajim/gtk/main_stack.py", "gajim/gtk/manage_sounds.py", "gajim/gtk/notification.py", + "gajim/gtk/password_dialog.py", "gajim/gtk/preview_audio.py", "gajim/gtk/proxies.py", "gajim/gtk/remove_account.py", View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/cd5c2899651383d864c2bbe463ced4a…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/cd5c2899651383d864c2bbe463ced4a…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: Interface: Handle roster-item-exchange event in MainWindow
by Philipp Hörist (@lovetox)
23 Jan '22
23 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 75b5ec5e by lovetox at 2022-01-23T12:10:34+01:00 Interface: Handle roster-item-exchange event in MainWindow - - - - - cd5c2899 by lovetox at 2022-01-23T12:11:19+01:00 Remove unused import - - - - - 5 changed files: - gajim/common/events.py - gajim/common/modules/roster_item_exchange.py - gajim/gtk/application.py - gajim/gtk/main.py - gajim/gui_interface.py Changes: ===================================== gajim/common/events.py ===================================== @@ -402,9 +402,9 @@ class MessageError(ApplicationEvent): @dataclass class RosterItemExchangeEvent(ApplicationEvent): - name: str = field(init=False, default='roster-item-exchange-received') - conn: 'Client' - fjid: str + name: str = field(init=False, default='roster-item-exchange') + client: 'Client' + jid: JID exchange_items_list: list[str] action: str ===================================== gajim/common/modules/roster_item_exchange.py ===================================== @@ -39,7 +39,7 @@ def __init__(self, con): ns=Namespace.ROSTERX), ] - def received_item(self, _con, stanza, _properties): + def received_item(self, _con, stanza, properties): # stanza can be a message or a iq self._log.info('Received roster items from %s', stanza.getFrom()) @@ -87,8 +87,8 @@ def received_item(self, _con, stanza, _properties): self._log.info('Items: %s', exchange_items_list) app.ged.raise_event(RosterItemExchangeEvent( - conn=self._con, - fjid=str(stanza.getFrom()), + client=self._con, + jid=properties.jid, exchange_items_list=exchange_items_list, action=action)) ===================================== gajim/gtk/application.py ===================================== @@ -62,7 +62,6 @@ from gajim.common.application import CoreApplication from gajim.common.const import GAJIM_FAQ_URI from gajim.common.const import GAJIM_WIKI_URI -from gajim.common.dbus import logind from gajim.common.dbus import music_track from gajim.common.events import ApplicationEvent from gajim.common.exceptions import GajimGeneralException ===================================== gajim/gtk/main.py ===================================== @@ -32,6 +32,7 @@ from gajim.common import ged from gajim.common.const import Direction from gajim.common.events import ApplicationEvent +from gajim.common.events import RosterItemExchangeEvent from gajim.common.events import AllowGajimUpdateCheck from gajim.common.events import GajimUpdateAvailable from gajim.common.events import AccountEnabled @@ -128,6 +129,7 @@ def __init__(self) -> None: ('account-disabled', ged.GUI1, self._on_account_disabled), ('allow-gajim-update-check', ged.GUI1, self._on_allow_gajim_update), ('gajim-update-available', ged.GUI1, self._on_gajim_update_available), + ('roster-item-exchange', ged.GUI1, self._on_roster_item_exchange), ]) self._check_for_account() @@ -196,6 +198,14 @@ def _on_allow_gajim_update(self, event: AllowGajimUpdateCheck) -> None: def _on_gajim_update_available(self, event: GajimUpdateAvailable) -> None: self.add_app_message(event.name, event.version) + @staticmethod + def _on_roster_item_exchange(event: RosterItemExchangeEvent) -> None: + open_window('RosterItemExchange', + account=event.client.account, + action=event.action, + exchange_list=event.exchange_items_list, + jid_from=event.jid) + def _add_actions(self) -> None: actions = [ ('add-workspace', 's', self._add_workspace), ===================================== gajim/gui_interface.py ===================================== @@ -154,7 +154,6 @@ def _create_core_handlers_list(self) -> None: 'message-sent': [self.handle_event_msgsent], 'message-not-sent': [self.handle_event_msgnotsent], 'read-state-sync': [self.handle_event_read_state_sync], - 'roster-item-exchange-received': [self.handle_event_roster_item_exchange], } # pylint: enable=line-too-long @@ -356,15 +355,6 @@ def handle_event_read_state_sync(event): app.window.mark_as_read(event.account, jid, send_marker=False) - @staticmethod - def handle_event_roster_item_exchange(event): - # data = (action in [add, delete, modify], exchange_list, jid_from) - open_window('RosterItemExchange', - account=event.conn.name, - action=event.action, - exchange_list=event.exchange_items_list, - jid_from=event.fjid) - # Jingle File Transfer @staticmethod def handle_event_file_error(title: str, message: str) -> None: View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/20d651f8c2cf2bd235d8145f07394d3…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/20d651f8c2cf2bd235d8145f07394d3…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: Interface: Move more code into Application
by Philipp Hörist (@lovetox)
23 Jan '22
23 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: da4e245a by lovetox at 2022-01-23T09:24:32+01:00 Interface: Move more code into Application - - - - - 20d651f8 by lovetox at 2022-01-23T11:58:20+01:00 Update README.md - - - - - 5 changed files: - README.md - gajim/common/application.py - gajim/common/dbus/logind.py - gajim/gtk/application.py - gajim/gui_interface.py Changes: ===================================== README.md ===================================== @@ -34,6 +34,10 @@ ### Compile-time Requirements - python3-setuptools - gettext +### Running Tests + +`python -m unittest discover -s test` + ### Installation Procedure #### Packages ===================================== gajim/common/application.py ===================================== @@ -74,6 +74,9 @@ def _init_core(self) -> None: if sys.platform in ('win32', 'darwin'): GLib.timeout_add_seconds(20, self._check_for_updates) + for account in app.settings.get_active_accounts(): + app.connections[account] = Client(account) + @property def _log(self) -> logging.Logger: return app.log('gajim.application') ===================================== gajim/common/dbus/logind.py ===================================== @@ -145,5 +145,10 @@ def _on_vanish_logind(self, _connection, name, *_user_data): def enable(): + # Module should be rewritten + # Its not useful to know when the computer goes to sleep. + # Because of stream management we don’t need to do anything in that case. + # It would be useful to know when the computer powers off, in this case + # Gajim is shutdown and we should correctly disconnect. return # LogindListener.get() ===================================== gajim/gtk/application.py ===================================== @@ -62,6 +62,8 @@ from gajim.common.application import CoreApplication from gajim.common.const import GAJIM_FAQ_URI from gajim.common.const import GAJIM_WIKI_URI +from gajim.common.dbus import logind +from gajim.common.dbus import music_track from gajim.common.events import ApplicationEvent from gajim.common.exceptions import GajimGeneralException from gajim.common.helpers import load_json @@ -235,6 +237,9 @@ def _startup(self, _application: GajimApplication) -> None: from gajim.gui.status_icon import StatusIcon self.systray = StatusIcon() + if sys.platform not in ('win32', 'darwin'): + music_track.enable() + self.add_actions() self._load_shortcuts() menus.build_accounts_menu() ===================================== gajim/gui_interface.py ===================================== @@ -61,8 +61,6 @@ from gajim.common import helpers from gajim.common import passwords -from gajim.common.dbus import logind -from gajim.common.dbus import music_track from gajim.common.events import AccountEnabled from gajim.common.events import AccountDisabled from gajim.common.events import FileCompleted @@ -125,12 +123,9 @@ def __init__(self): self._create_core_handlers_list() self._register_core_handlers() - for account in app.settings.get_accounts(): - if app.settings.get_account_setting(account, 'active'): - client = Client(account) - app.connections[account] = client - app.ged.register_event_handler( - 'muc-added', ged.CORE, self._on_muc_added) + app.ged.register_event_handler('muc-added', + ged.CORE, + self._on_muc_added) self.instances = {} @@ -145,10 +140,6 @@ def __init__(self): app.nicks[acc] = app.settings.get_account_setting(acc, 'name') app.block_signed_in_notifications[acc] = True - if sys.platform not in ('win32', 'darwin'): - logind.enable() - music_track.enable() - def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long self.handlers = { View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5ff99a655c405606ddba6a6ef7c4e38…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5ff99a655c405606ddba6a6ef7c4e38…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] Refactor UserTune/UserLocation
by Philipp Hörist (@lovetox)
22 Jan '22
22 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 5ff99a65 by lovetox at 2022-01-23T00:42:05+01:00 Refactor UserTune/UserLocation - Add info back to tooltips - Remove info from ChatControls - Issue events via contacts - - - - - 13 changed files: - gajim/common/client.py - gajim/common/const.py - gajim/common/events.py - gajim/common/modules/base.py - gajim/common/modules/contacts.py - gajim/common/modules/user_location.py - gajim/common/modules/user_tune.py - gajim/common/types.py - gajim/data/gui/chat_control.ui - gajim/gtk/builder.pyi - gajim/gtk/controls/chat.py - gajim/gtk/tooltips.py - gajim/gtk/util.py Changes: ===================================== gajim/common/client.py ===================================== @@ -81,7 +81,6 @@ def __init__(self, account: str) -> None: self._connect_machine_calls = 0 self.addressing_supported = False - self.pep = {} self.roster_supported = True self._state = ClientState.DISCONNECTED ===================================== gajim/common/const.py ===================================== @@ -14,7 +14,8 @@ from __future__ import annotations -from typing import Any, Union +from typing import Any +from typing import Union from typing import NamedTuple from enum import IntEnum @@ -178,19 +179,6 @@ class IdleState(Enum): AWAKE = 'online' -@unique -class PEPEventType(IntEnum): - ABSTRACT = 0 - ACTIVITY = 1 - TUNE = 2 - MOOD = 3 - LOCATION = 4 - NICKNAME = 5 - AVATAR = 6 - ATOM = 7 - BOOKMARKS = 8 - - class SyncThreshold(IntEnum): NO_SYNC = -1 NO_THRESHOLD = 0 ===================================== gajim/common/events.py ===================================== @@ -24,7 +24,6 @@ from dataclasses import field from nbxmpp.protocol import JID -from nbxmpp.structs import LocationData from nbxmpp.structs import RosterItem from nbxmpp.structs import TuneData from nbxmpp.const import InviteType @@ -435,24 +434,6 @@ class PluginRemoved(ApplicationEvent): plugin: Any -@dataclass -class TuneReceived(ApplicationEvent): - name: str = field(init=False, default='tune-received') - account: str - jid: str - tune: TuneData - is_self_message: bool - - -@dataclass -class LocationReceived(ApplicationEvent): - name: str = field(init=False, default='location-received') - account: str - jid: str - location: LocationData - is_self_message: bool - - @dataclass class SearchFormReceivedEvent(ApplicationEvent): name: str = field(init=False, default='search-form-received') ===================================== gajim/common/modules/base.py ===================================== @@ -22,6 +22,7 @@ from unittest.mock import Mock from nbxmpp.namespaces import Namespace +from nbxmpp.protocol import JID from nbxmpp.structs import StanzaHandler from gajim.common import types @@ -39,7 +40,7 @@ def __init__(self, con: types.Client, *args: Any, plugin: bool = False, - **kwargs: Any): + **kwargs: Any) -> None: EventHelper.__init__(self) self._con = con @@ -89,7 +90,7 @@ def _nbxmpp(self, module_name: Optional[str] = None): return self._con.connection return self._con.connection.get_module(module_name) - def _register_callback(self, method, callback): + def _register_callback(self, method, callback) -> None: self._nbxmpp_callbacks[method] = callback def _register_pubsub_handler(self, callback: types.AnyCallableT): @@ -105,7 +106,9 @@ def send_stored_publish(self) -> None: self._log.info('Send stored publish') self._stored_publish() # pylint: disable=not-callable - def _get_contact(self, jid, groupchat: bool = False): + def _get_contact(self, + jid: JID, + groupchat: bool = False) -> types.ContactT: return self._con.get_module('Contacts').get_contact( jid, groupchat=groupchat) ===================================== gajim/common/modules/contacts.py ===================================== @@ -28,6 +28,8 @@ from nbxmpp.const import Role from nbxmpp.protocol import JID from nbxmpp.structs import DiscoInfo +from nbxmpp.structs import LocationData +from nbxmpp.structs import TuneData from nbxmpp.structs import MucSubject from gajim.common import app @@ -119,10 +121,7 @@ def add_contact(self, def get_contact(self, jid: Union[str, JID], - groupchat: bool = False) -> Union[BareContact, - ResourceContact, - GroupchatContact, - GroupchatParticipant]: + groupchat: bool = False) -> types.ContactT: if isinstance(jid, str): jid = JID.from_string(jid) @@ -301,6 +300,12 @@ def name(self) -> str: return self._jid.domain return self._jid.localpart + def get_tune(self) -> Optional[TuneData]: + return self._module('UserTune').get_contact_tune(self._jid) + + def get_location(self) -> Optional[LocationData]: + return self._module('UserLocation').get_contact_location(self._jid) + @property def avatar_sha(self) -> Optional[str]: return app.storage.cache.get_contact(self._jid, 'avatar') ===================================== gajim/common/modules/user_location.py ===================================== @@ -14,10 +14,14 @@ # XEP-0080: User Location +from __future__ import annotations + +from typing import Optional + from nbxmpp.namespaces import Namespace +from nbxmpp.protocol import JID +from nbxmpp.structs import LocationData -from gajim.common import app -from gajim.common.events import LocationReceived from gajim.common.modules.base import BaseModule from gajim.common.modules.util import event_node from gajim.common.modules.util import store_publish @@ -30,16 +34,19 @@ class UserLocation(BaseModule): 'set_location', ] - def __init__(self, con): + def __init__(self, con) -> None: BaseModule.__init__(self, con) self._register_pubsub_handler(self._location_received) - self._current_location = None - self._locations = {} + self._current_location: Optional[LocationData] = None + self._contact_locations: dict[JID, LocationData] = {} - def get_current_location(self): + def get_current_location(self) -> Optional[LocationData]: return self._current_location + def get_contact_location(self, jid: JID) -> Optional[LocationData]: + return self._contact_locations.get(jid) + @event_node(Namespace.LOCATION) def _location_received(self, _con, _stanza, properties): if properties.pubsub_event.retracted: @@ -48,15 +55,11 @@ def _location_received(self, _con, _stanza, properties): data = properties.pubsub_event.data if properties.is_self_message: self._current_location = data - else: - self._locations[properties.jid] = data - - app.ged.raise_event( - LocationReceived( - account=self._account, - jid=properties.jid.bare, - location=data, - is_self_message=properties.is_self_message)) + + self._contact_locations[properties.jid] = data + + contact = self._get_contact(properties.jid) + contact.notify('location-update', data) @store_publish def set_location(self, location): ===================================== gajim/common/modules/user_tune.py ===================================== @@ -14,11 +14,16 @@ # XEP-0118: User Tune +from __future__ import annotations + +from typing import Optional + from nbxmpp.namespaces import Namespace +from nbxmpp.protocol import JID +from nbxmpp.structs import TuneData from gajim.common import app from gajim.common import ged -from gajim.common.events import TuneReceived from gajim.common.modules.base import BaseModule from gajim.common.modules.util import event_node from gajim.common.modules.util import store_publish @@ -36,16 +41,19 @@ class UserTune(BaseModule): def __init__(self, con): BaseModule.__init__(self, con) self._register_pubsub_handler(self._tune_received) - self._tune_data = None - self._tunes = {} + self._current_tune: Optional[TuneData] = None + self._contact_tunes: dict[JID, TuneData] = {} self.register_events([ ('music-track-changed', ged.CORE, self._on_music_track_changed), ('signed-in', ged.CORE, self._on_signed_in), ]) - def get_current_tune(self): - return self._tune_data + def get_current_tune(self) -> Optional[TuneData]: + return self._current_tune + + def get_contact_tune(self, jid: JID) -> Optional[TuneData]: + return self._contact_tunes.get(jid) @event_node(Namespace.TUNE) def _tune_received(self, _con, _stanza, properties): @@ -54,15 +62,12 @@ def _tune_received(self, _con, _stanza, properties): data = properties.pubsub_event.data if properties.is_self_message: - self._tune_data = data - else: - self._tunes[properties.jid] = data + self._current_tune = data + + self._contact_tunes[properties.jid] = data - app.ged.raise_event(TuneReceived( - account=self._account, - jid=properties.jid.bare, - tune=data, - is_self_message=properties.is_self_message)) + contact = self._get_contact(properties.jid) + contact.notify('tune-update', data) @store_publish def set_tune(self, tune): @@ -72,10 +77,10 @@ def set_tune(self, tune): if not app.settings.get_account_setting(self._account, 'publish_tune'): return - if tune == self._tune_data: + if tune == self._current_tune: return - self._tune_data = tune + self._current_tune = tune self._log.info('Send %s', tune) self._nbxmpp('Tune').set_tune(tune) @@ -101,7 +106,7 @@ def _on_signed_in(self, _event): self._publish_current_tune() def _on_music_track_changed(self, event): - if self._tune_data == event.info: + if self._current_tune == event.info: return self.set_tune(event.info) ===================================== gajim/common/types.py ===================================== @@ -45,6 +45,11 @@ from gajim.common.settings import Settings from gajim.gtk.css_config import CSSConfig + ContactT = Union[BareContact, + ResourceContact, + GroupchatContact, + GroupchatParticipant] + InterfaceT = Union['Interface'] ===================================== gajim/data/gui/chat_control.ui ===================================== @@ -224,47 +224,7 @@ </packing> </child> <child> - <object class="GtkBox" id="hbox2"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="spacing">4</property> - <child> - <object class="GtkImage" id="tune_image"> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="icon_size">1</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkEventBox" id="location_eventbox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="visible-window">False</property> - <child> - <object class="GtkImage" id="location_image"> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="icon_size">1</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">3</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> + <placeholder/> </child> </object> </child> ===================================== gajim/gtk/builder.pyi ===================================== @@ -210,10 +210,6 @@ class ChatControlBuilder(Builder): banner_label: Gtk.Label phone_image: Gtk.Image account_badge_box: Gtk.Box - hbox2: Gtk.Box - tune_image: Gtk.Image - location_eventbox: Gtk.EventBox - location_image: Gtk.Image conv_view_overlay: Gtk.Overlay hbox: Gtk.Box emoticons_button: Gtk.MenuButton ===================================== gajim/gtk/controls/chat.py ===================================== @@ -52,7 +52,6 @@ from gajim.common.const import AvatarSize from gajim.common.const import SimpleClientState from gajim.common.const import KindConstant -from gajim.common.const import PEPEventType from gajim.common.jingle_session import JingleSession from gajim.common.modules.contacts import BareContact @@ -63,7 +62,6 @@ from gajim.gui.const import ControlType from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ConfirmationDialog -from gajim.gui.util import get_cursor from gajim.gui.util import open_window from gajim.command_system.implementation.hosts import ChatCommands @@ -125,21 +123,8 @@ def __init__(self, account: str, jid: JID) -> None: self.xml.settings_menu.set_menu_model(self.control_menu) self.update_toolbar() - self.update_all_pep_types() self._update_avatar() - # Hook up signals - widget = self.xml.location_eventbox - id_ = widget.connect('button-release-event', - self.on_location_eventbox_button_release_event) - self.handlers[id_] = widget - id_ = widget.connect('enter-notify-event', - self.on_location_eventbox_enter_notify_event) - self.handlers[id_] = widget - id_ = widget.connect('leave-notify-event', - self.on_location_eventbox_leave_notify_event) - self.handlers[id_] = widget - self.setup_seclabel() self.add_actions() self.update_ui() @@ -333,43 +318,6 @@ def _on_send_marker(self, action.set_state(param) self.contact.settings.set('send_marker', param.get_boolean()) - def update_all_pep_types(self) -> None: - self._update_pep(PEPEventType.LOCATION) - self._update_pep(PEPEventType.TUNE) - - def _update_pep(self, type_: PEPEventType) -> None: - return - # TODO - # image = self._get_pep_widget(type_) - # data = self.contact.pep.get(type_) - # if data is None: - # image.hide() - # return - - # if type_ == PEPEventType.TUNE: - # icon = 'audio-x-generic' - # formated_text = format_tune(*data) - # elif type_ == PEPEventType.LOCATION: - # icon = 'applications-internet' - # formated_text = format_location(data) - - # image.set_from_icon_name(icon, Gtk.IconSize.MENU) - # image.set_tooltip_markup(formated_text) - # image.show() - - def _get_pep_widget(self, type_: PEPEventType) -> Optional[Gtk.Image]: - if type_ == PEPEventType.TUNE: - return self.xml.tune_image - if type_ == PEPEventType.LOCATION: - return self.xml.location_image - return None - - def _on_tune_received(self, _event: events.TuneReceived) -> None: - self._update_pep(PEPEventType.TUNE) - - def _on_location_received(self, _event: events.LocationReceived) -> None: - self._update_pep(PEPEventType.LOCATION) - def _on_nickname_received(self, _event): self.update_ui() @@ -529,27 +477,6 @@ def _add_incoming_call(self, ) -> None: self.add_call_message(event) - def on_location_eventbox_button_release_event(self, _widget, _event): - return - # TODO - # if 'geoloc' in self.contact.pep: - # location = self.contact.pep['geoloc'].data - # if 'lat' in location and 'lon' in location: - # uri = geo_provider_from_location(location['lat'], - # location['lon']) - # open_uri(uri) - - def on_location_eventbox_leave_notify_event(self, _widget, _event): - """ - Just moved the mouse so show the cursor - """ - cursor = get_cursor('default') - app.window.get_window().set_cursor(cursor) - - def on_location_eventbox_enter_notify_event(self, _widget, _event): - cursor = get_cursor('pointer') - app.window.get_window().set_cursor(cursor) - def update_ui(self) -> None: BaseControl.update_ui(self) self.update_toolbar() ===================================== gajim/gtk/tooltips.py ===================================== @@ -41,7 +41,6 @@ from gajim.common import types from gajim.common import helpers from gajim.common.const import AvatarSize -from gajim.common.const import PEPEventType from gajim.common.i18n import Q_ from gajim.common.i18n import _ from gajim.common.file_props import FileProp @@ -174,9 +173,7 @@ def _populate_grid(self, contact: types.BareContact) -> None: self._ui.sub.show() self._ui.sub_label.show() - # PEP info - # TODO - # self._append_pep_info(contact) + self._append_pep_info(contact) app.plugin_manager.gui_extension_point( 'roster_tooltip_populate', self, contact) @@ -251,15 +248,17 @@ def _add_resources(self, contact: types.BareContact) -> None: self._ui.resources_box.show_all() def _append_pep_info(self, contact: types.BareContact) -> None: - if PEPEventType.TUNE in contact.pep: - tune = format_tune(*contact.pep[PEPEventType.TUNE]) - self._ui.tune.set_markup(tune) + tune = contact.get_tune() + if tune is not None: + tune_str = format_tune(tune) + self._ui.tune.set_markup(tune_str) self._ui.tune.show() self._ui.tune_label.show() - if PEPEventType.LOCATION in contact.pep: - location = format_location(contact.pep[PEPEventType.LOCATION]) - self._ui.location.set_markup(location) + location = contact.get_location() + if location is not None: + location_str = format_location(location) + self._ui.location.set_markup(location_str) self._ui.location.show() self._ui.location_label.show() ===================================== gajim/gtk/util.py ===================================== @@ -46,6 +46,7 @@ import nbxmpp from nbxmpp import JID from nbxmpp.structs import LocationData +from nbxmpp.structs import TuneData from gajim.common import app from gajim.common import configpaths @@ -493,11 +494,10 @@ def func_wrapper(self, *args, **kwargs): return func_wrapper -def format_tune(artist: str, _length: str, _rating: str, source: str, - title: str, _track: str, _uri: str) -> str: - artist = GLib.markup_escape_text(artist or _('Unknown Artist')) - title = GLib.markup_escape_text(title or _('Unknown Title')) - source = GLib.markup_escape_text(source or _('Unknown Source')) +def format_tune(data: TuneData) -> str: + artist = GLib.markup_escape_text(data.artist or _('Unknown Artist')) + title = GLib.markup_escape_text(data.title or _('Unknown Title')) + source = GLib.markup_escape_text(data.source or _('Unknown Source')) tune_string = _('<b>"%(title)s"</b> by <i>%(artist)s</i>\n' 'from <i>%(source)s</i>') % {'title': title, View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/5ff99a655c405606ddba6a6ef7c4e387…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/5ff99a655c405606ddba6a6ef7c4e387…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
17
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Results per page:
10
25
50
100
200