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
----- 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
17632 discussions
Start a n
N
ew thread
[Git][gajim/gajim][master] chore: Remote: Fix pylint errors
by Philipp Hörist (ï¼ lovetox)
17 Jun '22
17 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 94c213ab by lovetox at 2022-06-17T16:10:28+02:00 chore: Remote: Fix pylint errors - - - - - 1 changed file: - gajim/common/dbus/remote_control.py Changes: ===================================== gajim/common/dbus/remote_control.py ===================================== @@ -407,5 +407,5 @@ def get_unread_msgs_number() -> str: return str(app.window.get_total_unread_count()) @staticmethod - def Introspect() -> str: + def Introspect() -> str: # pylint: disable=invalid-name return INTERFACE_DESC View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/94c213ab598555d27b785d64a185cb49…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/94c213ab598555d27b785d64a185cb49…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: feat: Rewrite gajim-remote
by Philipp Hörist (ï¼ lovetox)
17 Jun '22
17 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 79dba5b3 by lovetox at 2022-06-17T14:42:00+02:00 feat: Rewrite gajim-remote - Rewrite using argparse and Gio - - - - - 64821fe3 by lovetox at 2022-06-17T14:42:00+02:00 chore: Remote: Fix pylint errors - - - - - 4 changed files: - debian/control - gajim/common/dbus/remote_control.py - gajim/gajim_remote.py - pyrightconfig.json Changes: ===================================== debian/control ===================================== @@ -45,7 +45,6 @@ Depends: Recommends: aspell-en | aspell-dictionary, ca-certificates, - dbus, fonts-noto-color-emoji, gir1.2-gsound-1.0, gir1.2-gspell-1, @@ -59,7 +58,6 @@ Recommends: gstreamer1.0-gtk3, notification-daemon, pulseaudio-utils | alsa-utils | sox | oss4-base, - python3-dbus (>=0.81), python3-sentry-sdk, Suggests: libxss1, ===================================== gajim/common/dbus/remote_control.py ===================================== @@ -244,18 +244,20 @@ def raise_signal(self, event_name: str, data: Any) -> None: event_name, GLib.Variant.new_tuple(get_dbus_struct(data))) - def get_status(self, account: str) -> str: + @staticmethod + def get_status(account: str) -> str: if not account: return helpers.get_global_show() return app.get_client(account).status - def get_status_message(self, account: str) -> str: + @staticmethod + def get_status_message(account: str) -> str: if not account: return str(helpers.get_global_status_message()) return app.get_client(account).status_message - def _send_message(self, - jid: str, + @staticmethod + def _send_message(jid: str, message: str, account: str, type_: str) -> bool: @@ -295,7 +297,8 @@ def send_groupchat_message(self, return self._send_message(jid, message, account, 'groupchat') - def change_status(self, status: str, message: str, account: str) -> bool: + @staticmethod + def change_status(status: str, message: str, account: str) -> bool: """ change_status(status, message, account). Account is optional - if not specified status is changed for all accounts @@ -325,7 +328,8 @@ def change_status(self, status: str, message: str, account: str) -> bool: message) # pyright: ignore return False - def list_accounts(self) -> list[str]: + @staticmethod + def list_accounts() -> list[str]: """ List register accounts """ @@ -336,7 +340,8 @@ def list_accounts(self) -> list[str]: result_array.append(account) return result_array - def account_info(self, account: str) -> dict[str, str]: + @staticmethod + def account_info(account: str) -> dict[str, str]: """ Show info on account: resource, jid, nick, prio, message """ @@ -371,8 +376,8 @@ def list_contacts(self, account: str) -> list[dict[str, GLib.Variant]]: result.append(item) return result - def _contacts_as_dbus_structure(self, - contact: BareContact + @staticmethod + def _contacts_as_dbus_structure(contact: BareContact ) -> dict[str, GLib.Variant]: """ Get info from list of Contact objects and create dbus dict @@ -397,8 +402,10 @@ def _contacts_as_dbus_structure(self, contact_dict['groups'] = groups.end() return contact_dict - def get_unread_msgs_number(self) -> str: + @staticmethod + def get_unread_msgs_number() -> str: return str(app.window.get_total_unread_count()) - def Introspect(self) -> str: + @staticmethod + def Introspect() -> str: return INTERFACE_DESC ===================================== gajim/gajim_remote.py ===================================== @@ -1,13 +1,5 @@ #!/usr/bin/env python3 -# Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT
gmail.com
> -# Nikos Kouremenos <kourem AT
gmail.com
> -# Copyright (C) 2005-2014 Yann Leboulanger <asterix AT
lagaule.org
> -# Copyright (C) 2006 Junglecow <junglecow AT
gmail.com
> -# Travis Shirk <travis AT
pobox.com
> -# Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT
lapin.org
> -# Copyright (C) 2007 Julien Pivotto <roidelapluie AT
gmail.com
> -# # This file is part of Gajim. # # Gajim is free software; you can redistribute it and/or modify @@ -22,448 +14,146 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. -# gajim-remote help will show you the D-BUS API of Gajim +from typing import Any -import os import sys -import locale -import signal -import warnings - -from gajim.common import exceptions -from gajim.common.i18n import _ -from gajim.common.i18n import Q_ - -signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application - -try: - PREFERRED_ENCODING = locale.getpreferredencoding() -except Exception: - PREFERRED_ENCODING = 'UTF-8' - -def send_error(error_message): - '''Writes error message to stderr and exits''' - print(error_message, file=sys.stderr) - sys.exit(1) - -try: - import dbus - import dbus.service -# import dbus.glib - # test if dbus-x11 is installed - bus = dbus.SessionBus() -except Exception: - print(_('D-Bus is not present on this machine or python module is missing')) - sys.exit(1) - -if not sys.warnoptions: - warnings.simplefilter("default") - -warnings.warn( - "gajim-remote is deprecated, use Gajim's DBus interface instead. " - "For further information see " - "
https://dev.gajim.org/gajim/gajim/-/wikis/help/GajimDBus
.", - DeprecationWarning -) +import argparse +import logging + +from gi.repository import GLib +from gi.repository import Gio + + +LOG_FORMAT = '%(asctime)s %(levelname)s %(message)s' +logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) +log = logging.getLogger() + OBJ_PATH = '/org/gajim/dbus/RemoteObject' INTERFACE = 'org.gajim.dbus.RemoteInterface' SERVICE = 'org.gajim.Gajim' -BASENAME = 'gajim-remote' - -class GajimRemote: - - def __init__(self): - self.argv_len = len(sys.argv) - # define commands dict. Prototype : - # { - # 'command': [comment, [list of arguments] ] - # } - # - # each argument is defined as a tuple: - # (argument name, help on argument, is mandatory) - # - self.commands = { - 'help': [ - _('Shows a help on specific command'), - [ - #User gets help for the command, specified by this parameter - (_('command'), - _('show help on command'), False) - ] - ], - 'list_contacts': [ - _('Lists all contacts in the contact list, one for each line'), - [ - (Q_('?CLI:account'), _('show only contacts of the given account'), - False) - ] - - ], - 'list_accounts': [ - _('Prints a list of registered accounts'), - [] - ], - 'change_status': [ - _('Changes the status of account(s)'), - [ -#offline, online, chat, away, xa, dnd should not be translated - (Q_('?CLI:status'), _('one of: offline, online, chat, away, xa, dnd. If not set, use account\'s previous status'), False), - (Q_('?CLI:message'), _('status message'), False), - (Q_('?CLI:account'), _('change status of account "account". ' - 'If not specified, try to change status of all accounts that have ' - '"sync with global status" option set'), False) - ] - ], - 'set_priority': [ - _('Changes the priority of account(s)'), - [ - (Q_('?CLI:priority'), _('priority you want to give to the account'), - True), - (Q_('?CLI:account'), _('change the priority of the given account. ' - 'If not specified, change status of all accounts that have' - ' "sync with global status" option set'), False) - ] - ], - 'send_chat_message': [ - _('Sends new chat message to a contact in the contact list. Account is optional.'), - [ - ('jid', _('XMPP Address of the contact that will receive the message'), True), - (Q_('?CLI:message'), _('message contents'), True), - (Q_('?CLI:account'), _('if specified, the message will be sent ' - 'using this account'), False), - ] - ], - 'send_single_message': [ - _('Sends a chat message to someone on your contact list. ' - 'Account is optional.'), - [ - ('jid', _('XMPP Address of the contact that will receive the message'), True), - (_('subject'), _('message subject'), True), - (Q_('?CLI:message'), _('message contents'), True), - (Q_('?CLI:account'), _('if specified, the message will be sent ' - 'using this account'), False), - ] - ], - 'send_groupchat_message': [ - _('Sends new message to a group chat you\'ve joined.'), - [ - ('room_jid', _('XMPP Address of the group chat that will receive the message'), True), - (Q_('?CLI:message'), _('message contents'), True), - (Q_('?CLI:account'), _('if specified, the message will be sent ' - 'using this account'), False), - ] - ], - 'contact_info': [ - _('Gets detailed info on a contact'), - [ - ('jid', _('XMPP Address of the contact'), True) - ] - ], - 'account_info': [ - _('Gets detailed info on a account'), - [ - ('account', _('Name of the account'), True) - ] - ], - 'send_file': [ - _('Sends file to a contact'), - [ - (_('file'), _('File path'), True), - ('jid', _('XMPP Address of the contact'), True), - (Q_('?CLI:account'), _('if specified, file will be sent using this ' - 'account'), False) - ] - ], - 'remove_contact': [ - _('Removes contact from contact list'), - [ - ('jid', _('XMPP Address of the contact'), True), - (Q_('?CLI:account'), _('if specified, contact is taken from the ' - 'contact list of this account'), False) - - ] - ], - - 'get_status': [ - _('Returns current status (the global one unless account is specified)'), - [ - (Q_('?CLI:account'), '', False) - ] - ], - - 'get_status_message': [ - _('Returns current status message (the global one unless account is specified)'), - [ - (Q_('?CLI:account'), '', False) - ] - ], - - 'get_unread_msgs_number': [ - _('Returns number of unread messages'), - [] - ], - - 'send_xml': [ - _('Sends custom XML'), - [ - ('xml', _('XML to send'), True), - ('account', _('Account to which the XML will be sent; ' - 'if not specified, XML will be sent to all accounts'), - False) - ] - ], - - 'check_gajim_running': [ - _('Check if Gajim is running'), - [] - ], - - } - - self.sbus = None - if self.argv_len < 2 or sys.argv[1] not in self.commands: - # no args or bad args - send_error(self.compose_help()) - self.command = sys.argv[1] - if self.command == 'help': - if self.argv_len == 3: - print(self.help_on_command(sys.argv[2]).encode( - PREFERRED_ENCODING)) - else: - print(self.compose_help().encode(PREFERRED_ENCODING)) - sys.exit(0) - if self.command == 'check_gajim_running': - print(self.check_gajim_running()) - sys.exit(0) - self.init_connection() - self.check_arguments() - - if self.command == 'contact_info': - if self.argv_len < 3: - send_error(_('Missing argument "contact_jid"')) - - try: - res = self.call_remote_method() - except exceptions.ServiceNotAvailable: - # At this point an error message has already been displayed - sys.exit(1) - else: - self.print_result(res) - - def print_result(self, res): - """ - Print retrieved result to the output - """ - if res is not None: - if self.command in ('send_chat_message', 'send_single_message'): - self.argv_len -= 2 - - if res is False: - if self.argv_len < 4: - send_error(_('\'%s\' is not in your contact list.\n' - 'Please specify account for sending the message.') % sys.argv[2]) - else: - send_error(_('You have no active account')) - elif self.command == 'list_accounts': - if isinstance(res, list): - for account in res: - print(account) - elif self.command == 'account_info': - if res: - print(self.print_info(0, res, True)) - elif self.command == 'list_contacts': - for account_dict in res: - print(self.print_info(0, account_dict, True)) - elif self.command == 'prefs_list': - pref_keys = sorted(res.keys()) - for pref_key in pref_keys: - result = '%s = %s' % (pref_key, res[pref_key]) - print(result) - elif self.command == 'contact_info': - print(self.print_info(0, res, True)) - elif res: - print(res) - - def check_gajim_running(self): - if not self.sbus: - try: - self.sbus = dbus.SessionBus() - except Exception: - raise exceptions.SessionBusNotPresent - - test = False - if hasattr(self.sbus, 'name_has_owner'): - if self.sbus.name_has_owner(SERVICE): - test = True - elif dbus.dbus_bindings.bus_name_has_owner(self.sbus.get_connection(), - SERVICE): - test = True - return test - - def init_connection(self): - """ - Create the connection to the session dbus, or exit if it is not possible - """ - try: - self.sbus = dbus.SessionBus() - except Exception: - raise exceptions.SessionBusNotPresent - - if not self.check_gajim_running(): - #Do not translate "gajim-remote" - send_error(_('It seems Gajim is not running. So you can\'t use gajim-remote.')) - obj = self.sbus.get_object(SERVICE, OBJ_PATH) - interface = dbus.Interface(obj, INTERFACE) - - # get the function asked - self.method = interface.__getattr__(self.command) - - def make_arguments_row(self, args): - """ - Return arguments list. Mandatory arguments are enclosed with: - '<', '>', optional arguments - with '[', ']' - """ - s = '' - for arg in args: - if arg[2]: - s += ' <' + arg[0] + '>' - else: - s += ' [' + arg[0] + ']' - return s - - def help_on_command(self, command): - """ - Return help message for a given command - """ - if command in self.commands: - command_props = self.commands[command] - arguments_str = self.make_arguments_row(command_props[1]) - str_ = _('Usage: %(basename)s %(command)s %(arguments)s \n\t %(help)s')\ - % {'basename': BASENAME, 'command': command, - 'arguments': arguments_str, 'help': command_props[0]} - if command_props[1]: - str_ += '\n\n' + _('Arguments:') + '\n' - for argument in command_props[1]: - str_ += ' ' + argument[0] + ' - ' + argument[1] + '\n' - return str_ - send_error(_('%s not found') % command) - - def compose_help(self): - """ - Print usage, and list available commands - """ - s = _('Usage:\n %s command [arguments]\n\nCommand is one of:\n') % ( - BASENAME) - for command in sorted(self.commands): - s += ' ' + command - for arg in self.commands[command][1]: - if arg[2]: - s += ' <' + arg[0] + '>' - else: - s += ' [' + arg[0] + ']' - s += '\n' - return s - - def print_info(self, level, prop_dict, encode_return=False): - """ - Return formatted string from data structure - """ - if prop_dict is None or not isinstance(prop_dict, (dict, list, tuple)): - return '' - ret_str = '' - if isinstance(prop_dict, (list, tuple)): - ret_str = '' - spacing = ' ' * level * 4 - for val in prop_dict: - if val is None: - ret_str += '\t' - elif isinstance(val, int): - ret_str += '\t' + str(val) - elif isinstance(val, str): - ret_str += '\t' + val - elif isinstance(val, (list, tuple)): - res = '' - for items in val: - res += self.print_info(level+1, items) - if res != '': - ret_str += '\t' + res - elif isinstance(val, dict): - ret_str += self.print_info(level+1, val) - ret_str = '%s(%s)\n' % (spacing, ret_str[1:]) - elif isinstance(prop_dict, dict): - for key in prop_dict.keys(): - val = prop_dict[key] - spacing = ' ' * level * 4 - if isinstance(val, (int, str)): - if val is not None: - val = val.strip() - ret_str += '%s%-10s: %s\n' % (spacing, key, val) - elif isinstance(val, (list, tuple)): - res = '' - for items in val: - res += self.print_info(level+1, items) - if res != '': - ret_str += '%s%s: \n%s' % (spacing, key, res) - elif isinstance(val, dict): - res = self.print_info(level+1, val) - if res != '': - ret_str += '%s%s: \n%s' % (spacing, key, res) - if encode_return: - try: - ret_str = ret_str.encode(PREFERRED_ENCODING) - except Exception: - pass - return ret_str - - def check_arguments(self): - """ - Make check if all necessary arguments are given - """ - argv_len = self.argv_len - 2 - args = self.commands[self.command][1] - if len(args) < argv_len: - send_error(_('Too many arguments. \n' - 'Type "%(basename)s help %(command)s" for more info') % { - 'basename': BASENAME, 'command': self.command}) - if len(args) > argv_len: - if args[argv_len][2]: - send_error(_('Argument "%(arg)s" is not specified. \n' - 'Type "%(basename)s help %(command)s" for more info') % - {'arg': args[argv_len][0], 'basename': BASENAME, - 'command': self.command}) - self.arguments = [] - i = 0 - for arg in sys.argv[2:]: - i += 1 - if i < len(args): - self.arguments.append(arg) - else: - # it's latest argument with spaces - self.arguments.append(' '.join(sys.argv[i+1:])) - break - # add empty string for missing args - self.arguments += ['']*(len(args)-i) - - def call_remote_method(self): - """ - Calls self.method with arguments from sys.argv[2:] - """ - args = [dbus.String(i) for i in self.arguments] - try: - res = self.method(*args) - return res - except Exception: - raise exceptions.ServiceNotAvailable - return None - - -def main(): - if os.geteuid() == 0: - sys.exit("You must not launch gajim as root, it is insecure.") - - GajimRemote() + +SIGNATURES = { + 'list_contacts': '(s)', + 'list_accounts': '()', + 'change_status': '(sss)', + 'send_chat_message': '(sss)', + 'send_groupchat_message': '(sss)', + 'account_info': '(s)', + 'get_status': '(s)', + 'get_status_message': '(s)', + 'get_unread_msgs_number': '()', +} + + +def call_method(args: argparse.Namespace) -> Any: + arg_dict = vars(args) + app_id = arg_dict.pop('app_id') + command = arg_dict.pop('command') + + proxy = Gio.DBusProxy.new_for_bus_sync( + Gio.BusType.SESSION, + Gio.DBusProxyFlags.NONE, + None, + app_id, + OBJ_PATH, + INTERFACE, + None) + + arguments = tuple(arg_dict.values()) + signature = SIGNATURES[command] + method = getattr(proxy, command) + return method(signature, *arguments) + + +def create_arg_parser() -> argparse.ArgumentParser: + + account_help = 'The account the command is executed for' + + parser = argparse.ArgumentParser(prog='gajim-remote') + parser.add_argument('--app-id', default=SERVICE) + + subparsers = parser.add_subparsers(required=True, + metavar='commands', + dest='command') + + subparser = subparsers.add_parser( + 'list_contacts', + help='Get all roster contacts') + subparser.add_argument('account', type=str) + + subparser = subparsers.add_parser( + 'list_accounts', + help='Get the list of accounts') + + subparser = subparsers.add_parser( + 'change_status', + help='Change the status') + subparser.add_argument('status', + choices=['offline', 'online', 'away', 'xa', 'dnd']) + subparser.add_argument('message', type=str) + subparser.add_argument('account', type=str) + + subparser = subparsers.add_parser( + 'send_chat_message', + help='Send a chat message to a contact') + subparser.add_argument('address', type=str, + help='The XMPP address of the contact') + subparser.add_argument('message', type=str, + help='The message to be sent') + subparser.add_argument('account', type=str, + help=account_help) + + subparser = subparsers.add_parser( + 'send_groupchat_message', + help='Send a chat message to a group chat') + subparser.add_argument('address', type=str, + help='The XMPP address of the group chat') + subparser.add_argument('message', type=str, + help='The message to be sent') + subparser.add_argument('account', type=str, + help=account_help) + + subparser = subparsers.add_parser( + 'account_info', + help='Get account details') + subparser.add_argument('account', type=str, help=account_help) + + subparser = subparsers.add_parser( + 'get_status', + help='Get the current status') + subparser.add_argument('account', type=str, help=account_help) + + subparser = subparsers.add_parser( + 'get_status_message', + help='Get the current status message') + subparser.add_argument('account', type=str, help=account_help) + + subparser = subparsers.add_parser( + 'get_unread_msgs_number', + help='Get the unread message count') + + return parser if __name__ == '__main__': - main() + args = create_arg_parser().parse_args() + try: + result = call_method(args) + except GLib.Error as error: + quark = GLib.quark_try_string('g-dbus-error-quark') + if error.matches(quark, Gio.DBusError.SERVICE_UNKNOWN): + log.error('Service not found. Check if Gajim is running. ' + 'If Gajim is running under a custom profile use ' + '--app-id=org.gajim.Gajim.myprofilename') + + else: + log.exception('Failed to execute method') + + sys.exit(1) + + except Exception: + log.exception('Failed to execute method') + sys.exit(1) + + print(result) ===================================== pyrightconfig.json ===================================== @@ -16,6 +16,7 @@ "scripts/*", "win/*", "gajim/gajim.py", + "gajim/gajim_remote.py", "gajim/common/dbus/*", "gajim/common/application.py", "gajim/common/call_manager.py", View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/7e24d615a37caf81f3d41b4dbea2694…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/7e24d615a37caf81f3d41b4dbea2694…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] imprv: Rework DBus Remote Interface
by Philipp Hörist (ï¼ lovetox)
16 Jun '22
16 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 7e24d615 by lovetox at 2022-06-16T20:39:27+02:00 imprv: Rework DBus Remote Interface - Add type annotations - Remove non-essential signals and methods - Refactor and simplify code - - - - - 3 changed files: - + gajim/common/dbus/remote_control.py - gajim/gui_interface.py - − gajim/remote_control.py Changes: ===================================== gajim/common/dbus/remote_control.py ===================================== @@ -0,0 +1,404 @@ +# This file is part of Gajim. +# +# Gajim is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 3 only. +# +# Gajim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. + +from typing import Any +from typing import cast + +import logging + +from gi.repository import GLib +from gi.repository import Gio + +from gajim.common import app +from gajim.common import ged +from gajim.common import helpers +from gajim.common import events +from gajim.common.structs import OutgoingMessage +from gajim.common.modules.contacts import BareContact + + +log = logging.getLogger('gajim.c.dbus.remote_control') + +INTERFACE_DESC = ''' +<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' +'
http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd
'> +<node> + <interface name='org.freedesktop.DBus.Introspectable'> + <method name='Introspect'> + <arg name='data' direction='out' type='s'/> + </method> + </interface> + <interface name='org.gajim.dbus.RemoteInterface'> + <method name='account_info'> + <arg name='account' type='s' /> + <arg direction='out' type='a{ss}' /> + </method> + <method name='change_status'> + <arg name='status' type='s' /> + <arg name='message' type='s' /> + <arg name='account' type='s' /> + <arg direction='out' type='b' /> + </method> + <method name='get_status'> + <arg name='account' type='s' /> + <arg direction='out' type='s' /> + </method> + <method name='get_status_message'> + <arg name='account' type='s' /> + <arg direction='out' type='s' /> + </method> + <method name='get_unread_msgs_number'> + <arg direction='out' type='s' /> + </method> + <method name='list_accounts'> + <arg direction='out' type='as' /> + </method> + <method name='list_contacts'> + <arg name='account' type='s' /> + <arg direction='out' type='aa{sv}' /> + </method> + <method name='send_chat_message'> + <arg name='jid' type='s' /> + <arg name='message' type='s' /> + <arg name='account' type='s' /> + <arg direction='out' type='b' /> + </method> + <method name='send_groupchat_message'> + <arg name='room_jid' type='s' /> + <arg name='message' type='s' /> + <arg name='account' type='s' /> + <arg direction='out' type='b' /> + </method> + <signal name='AccountPresence'> + <arg type='av' /> + </signal> + <signal name='ContactPresence'> + <arg type='av' /> + </signal> + <signal name='GCMessage'> + <arg type='av' /> + </signal> + <signal name='MessageSent'> + <arg type='av' /> + </signal> + <signal name='NewMessage'> + <arg type='av' /> + </signal> + </interface> +</node> +''' + + +def get_dbus_struct(obj: Any) -> GLib.Variant: + """ + Recursively go through all the items and replace them with their casted dbus + equivalents + """ + if isinstance(obj, str): + return GLib.Variant('s', obj) + if isinstance(obj, int): + return GLib.Variant('i', obj) + if isinstance(obj, float): + return GLib.Variant('d', obj) + if isinstance(obj, bool): + return GLib.Variant('b', obj) + if isinstance(obj, (list, tuple)): + lst = [get_dbus_struct(i) for i in obj # pyright: ignore + if i is not None] + result = GLib.Variant('av', lst) + return result + if isinstance(obj, dict): + obj = cast(dict[str, Any], obj) + result = GLib.VariantDict() + for key, value in obj.items(): + result.insert_value(key, get_dbus_struct(value)) + return result.end() + # unknown type + return GLib.Variant('s', str(obj)) + + +class Server: + def __init__(self, con: Gio.DBusConnection, path: str) -> None: + self._method_outargs: dict[str, str] = {} + self._method_inargs: dict[str, tuple[str, ...]] = {} + node_info = Gio.DBusNodeInfo.new_for_xml(INTERFACE_DESC) + for interface in node_info.interfaces: + for method in interface.methods: + self._method_outargs[method.name] = '(' + ''.join( + [arg.signature for arg in method.out_args]) + ')' + self._method_inargs[method.name] = tuple( + arg.signature for arg in method.in_args) + + con.register_object( + object_path=path, + interface_info=interface, + method_call_closure=self._on_method_call) + + def _on_method_call(self, + _connection: Gio.DBusConnection, + _sender: str, + _object_path: str, + _interface_name: str, + method_name: str, + parameters: GLib.Variant, + invocation: Gio.DBusMethodInvocation) -> None: + + args = list(parameters.unpack()) + for i, sig in enumerate(self._method_inargs[method_name]): + if sig == 'h': + msg = invocation.get_message() + fd_list = msg.get_unix_fd_list() + args[i] = fd_list.get(args[i]) + + result = getattr(self, method_name)(*args) + + # out_args is at least (signature1). We therefore always wrap the result + # as a tuple. Refer to
https://bugzilla.gnome.org/show_bug.cgi?id=765603
+ result = (result, ) + + out_args = self._method_outargs[method_name] + if out_args != '()': + variant = GLib.Variant(out_args, result) + invocation.return_value(variant) + else: + invocation.return_value(None) + + +class GajimRemote(Server): + def __init__(self) -> None: + self._con = Gio.bus_get_sync(Gio.BusType.SESSION, None) + Gio.bus_own_name_on_connection(self._con, 'org.gajim.Gajim', + Gio.BusNameOwnerFlags.NONE, None, None) + super().__init__(self._con, '/org/gajim/dbus/RemoteObject') + + app.ged.register_event_handler('presence-received', + ged.POSTGUI, + self._on_presence_received) + app.ged.register_event_handler('gc-message-received', + ged.POSTGUI, + self._on_gc_message_received) + app.ged.register_event_handler('message-received', + ged.POSTGUI, + self._on_message_received) + app.ged.register_event_handler('our-show', + ged.POSTGUI, + self._on_our_status) + app.ged.register_event_handler('message-sent', + ged.POSTGUI, + self._on_message_sent) + + def _on_message_sent(self, event: events.MessageSent) -> None: + self.raise_signal('MessageSent', ( + event.account, [event.jid, + event.message])) + + def _on_presence_received(self, event: events.PresenceReceived) -> None: + self.raise_signal('ContactPresence', (event.account, [ + event.jid, + event.resource, + event.show, + event.status])) + + def _on_gc_message_received(self, event: events.GcMessageReceived) -> None: + self.raise_signal('GCMessage', ( + event.conn.name, [event.fjid, + event.msgtxt, + event.properties.timestamp, + event.delayed, + event.displaymarking])) + + def _on_message_received(self, + event: events.MessageReceived) -> None: + + event_type = event.properties.type.value + if event.properties.is_muc_pm: + event_type = 'pm' + self.raise_signal('NewMessage', ( + event.conn.name, [event.fjid, + event.msgtxt, + event.properties.timestamp, + event_type, + event.properties.subject, + event.msg_log_id, + event.properties.nickname])) + + def _on_our_status(self, event: events.ShowChanged) -> None: + self.raise_signal('AccountPresence', (event.show, event.account)) + + def raise_signal(self, event_name: str, data: Any) -> None: + log.info('Send event %s', event_name) + self._con.emit_signal(None, + '/org/gajim/dbus/RemoteObject', + 'org.gajim.dbus.RemoteInterface', + event_name, + GLib.Variant.new_tuple(get_dbus_struct(data))) + + def get_status(self, account: str) -> str: + if not account: + return helpers.get_global_show() + return app.get_client(account).status + + def get_status_message(self, account: str) -> str: + if not account: + return str(helpers.get_global_status_message()) + return app.get_client(account).status_message + + def _send_message(self, + jid: str, + message: str, + account: str, + type_: str) -> bool: + + if not app.account_is_available(account): + return False + + client = app.get_client(account) + contact = client.get_module('Contacts').get_contact( + jid, groupchat=type_ == 'groupchat') + + if type_ == 'groupchat': + if not contact.is_joined: + return False + + message_ = OutgoingMessage(account=account, + contact=contact, + message=message, + type_=type_) + + app.get_client(account).send_message(message_) + return True + + def send_chat_message(self, jid: str, message: str, account: str) -> bool: + if not jid or not message or not account: + return False + + return self._send_message(jid, message, account, 'chat') + + def send_groupchat_message(self, + jid: str, + message: str, + account: str) -> bool: + + if not jid or not message or not account: + return False + + return self._send_message(jid, message, account, 'groupchat') + + def change_status(self, status: str, message: str, account: str) -> bool: + """ + change_status(status, message, account). Account is optional - if not + specified status is changed for all accounts + """ + if status not in ('offline', 'online', 'chat', 'away', 'xa', 'dnd'): + status = '' + if account: + if not status: + if account not in app.connections: + return False + status = app.connections[account].status + GLib.idle_add(app.connections[account].change_status, status, + message) # pyright: ignore + else: + # account not specified, so change the status of all accounts + for acc in app.settings.get_active_accounts(): + if not app.settings.get_account_setting( + acc, 'sync_with_global_status'): + continue + if status: + status_ = status + else: + if acc not in app.connections: + continue + status_ = app.connections[acc].status + GLib.idle_add(app.connections[acc].change_status, status_, + message) # pyright: ignore + return False + + def list_accounts(self) -> list[str]: + """ + List register accounts + """ + result = app.settings.get_active_accounts() + result_array: list[str] = [] + if result: + for account in result: + result_array.append(account) + return result_array + + def account_info(self, account: str) -> dict[str, str]: + """ + Show info on account: resource, jid, nick, prio, message + """ + result: dict[str, str] = {} + if account in app.connections: + # account is valid + con = app.connections[account] + result['status'] = con.status + result['name'] = con.name + result['jid'] = app.get_jid_from_account(con.name) + result['message'] = con.status_message + result['priority'] = str(con.priority) + result['resource'] = app.settings.get_account_setting(con.name, + 'resource') + return result + + def list_contacts(self, account: str) -> list[dict[str, GLib.Variant]]: + result: list[dict[str, GLib.Variant]] = [] + accounts = app.settings.get_active_accounts() + if not accounts: + return result + if account: + accounts_to_search = [account] + else: + accounts_to_search = accounts + for acct in accounts_to_search: + if acct in accounts: + client = app.get_client(acct) + for contact in client.get_module('Roster').iter_contacts(): + item = self._contacts_as_dbus_structure(contact) + if item: + result.append(item) + return result + + def _contacts_as_dbus_structure(self, + contact: BareContact + ) -> dict[str, GLib.Variant]: + """ + Get info from list of Contact objects and create dbus dict + """ + + contact_dict: dict[str, GLib.Variant] = {} + + contact_dict['name'] = GLib.Variant('s', contact.name) + contact_dict['show'] = GLib.Variant('s', contact.show.value) + contact_dict['jid'] = GLib.Variant('s', str(contact.jid)) + + resources = GLib.VariantBuilder(GLib.VariantType('a(ss)')) + for res_contact in contact.iter_resources(): + resource_props = (res_contact.resource, + res_contact.status) + resources.add_value(GLib.Variant('(ss)', resource_props)) + contact_dict['resources'] = resources.end() + + groups = GLib.VariantBuilder(GLib.VariantType('as')) + for group in contact.groups: + groups.add_value(GLib.Variant('s', group)) + contact_dict['groups'] = groups.end() + return contact_dict + + def get_unread_msgs_number(self) -> str: + return str(app.window.get_total_unread_count()) + + def Introspect(self) -> str: + return INTERFACE_DESC ===================================== gajim/gui_interface.py ===================================== @@ -697,7 +697,7 @@ def run(self, _application: Gtk.Application) -> None: def remote_init(): if app.settings.get('remote_control'): try: - from gajim import remote_control + from gajim.common.dbus import remote_control remote_control.GajimRemote() except Exception: log.exception('Failed to init remote control') ===================================== gajim/remote_control.py deleted ===================================== @@ -1,743 +0,0 @@ -# Copyright (C) 2005-2006 Andrew Sayman <lorien420 AT
myrealbox.com
> -# Dimitur Kirov <dkirov AT
gmail.com
> -# Nikos Kouremenos <kourem AT
gmail.com
> -# Copyright (C) 2005-2014 Yann Leboulanger <asterix AT
lagaule.org
> -# Copyright (C) 2006-2007 Travis Shirk <travis AT
pobox.com
> -# Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT
lapin.org
> -# Copyright (C) 2007 Lukas Petrovicky <lukas AT
petrovicky.net
> -# Julien Pivotto <roidelapluie AT
gmail.com
> -# Copyright (C) 2008 Jonathan Schleifer <js-gajim AT
webkeks.org
> -# -# This file is part of Gajim. -# -# Gajim is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Gajim is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. - -from typing import Any - -import os -import logging - -from gi.repository import GLib -from gi.repository import Gio - -from gajim.common import app -from gajim.common import ged -from gajim.common import helpers -from gajim.common import events -from gajim.common.structs import OutgoingMessage -from gajim.common.modules.contacts import BareContact - -from gajim.gui.add_contact import AddContact - - -log = logging.getLogger('gajim.remote_control') - - -def get_dbus_struct(obj): - """ - Recursively go through all the items and replace them with their casted dbus - equivalents - """ - if obj is None: - return None - if isinstance(obj, str): - return GLib.Variant('s', obj) - if isinstance(obj, int): - return GLib.Variant('i', obj) - if isinstance(obj, float): - return GLib.Variant('d', obj) - if isinstance(obj, bool): - return GLib.Variant('b', obj) - if isinstance(obj, (list, tuple)): - lst = [get_dbus_struct(i) for i in obj if i is not None] - result = GLib.Variant('av', lst) - return result - if isinstance(obj, dict): - result = GLib.VariantDict() - for key, value in obj.items(): - result.insert_value(key, get_dbus_struct(value)) - return result.end() - # unknown type - return GLib.Variant('s', str(obj)) - - -class Server: - def __init__(self, con, path): - method_outargs = {} - method_inargs = {} - for interface in Gio.DBusNodeInfo.new_for_xml(self.__doc__).interfaces: - - for method in interface.methods: - method_outargs[method.name] = '(' + ''.join( - [arg.signature for arg in method.out_args]) + ')' - method_inargs[method.name] = tuple( - arg.signature for arg in method.in_args) - - con.register_object( - object_path=path, - interface_info=interface, - method_call_closure=self.on_method_call) - - self.method_inargs = method_inargs - self.method_outargs = method_outargs - - def on_method_call(self, connection, sender, object_path, interface_name, - method_name, parameters, invocation): - - args = list(parameters.unpack()) - for i, sig in enumerate(self.method_inargs[method_name]): - if sig == 'h': - msg = invocation.get_message() - fd_list = msg.get_unix_fd_list() - args[i] = fd_list.get(args[i]) - - result = getattr(self, method_name)(*args) - - # out_args is at least (signature1). We therefore always wrap the result - # as a tuple. Refer to
https://bugzilla.gnome.org/show_bug.cgi?id=765603
- result = (result, ) - - out_args = self.method_outargs[method_name] - if out_args != '()': - variant = GLib.Variant(out_args, result) - invocation.return_value(variant) - else: - invocation.return_value(None) - - -class GajimRemote(Server): - ''' - <!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' - '
http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd
'> - <node> - <interface name='org.freedesktop.DBus.Introspectable'> - <method name='Introspect'> - <arg name='data' direction='out' type='s'/> - </method> - </interface> - <interface name='org.gajim.dbus.RemoteInterface'> - <method name='account_info'> - <arg name='account' type='s' /> - <arg direction='out' type='a{ss}' /> - </method> - <method name='add_contact'> - <arg name='jid' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='change_status'> - <arg name='status' type='s' /> - <arg name='message' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='get_status'> - <arg name='account' type='s' /> - <arg direction='out' type='s' /> - </method> - <method name='get_status_message'> - <arg name='account' type='s' /> - <arg direction='out' type='s' /> - </method> - <method name='get_unread_msgs_number'> - <arg direction='out' type='s' /> - </method> - <method name='join_room'> - <arg name='room_jid' type='s' /> - <arg name='password' type='s' /> - <arg name='account' type='s' /> - </method> - <method name='list_accounts'> - <arg direction='out' type='as' /> - </method> - <method name='list_contacts'> - <arg name='account' type='s' /> - <arg direction='out' type='aa{sv}' /> - </method> - <method name='open_chat'> - <arg name='jid' type='s' /> - <arg name='account' type='s' /> - <arg name='message' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='remove_contact'> - <arg name='jid' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='send_chat_message'> - <arg name='jid' type='s' /> - <arg name='message' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='send_file'> - <arg name='file_path' type='s' /> - <arg name='jid' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='send_groupchat_message'> - <arg name='room_jid' type='s' /> - <arg name='message' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='send_single_message'> - <arg name='jid' type='s' /> - <arg name='subject' type='s' /> - <arg name='message' type='s' /> - <arg name='account' type='s' /> - <arg direction='out' type='b' /> - </method> - <method name='send_xml'> - <arg name='xml' type='s' /> - <arg name='account' type='s' /> - </method> - <method name='set_priority'> - <arg name='prio' type='s' /> - <arg name='account' type='s' /> - </method> - <signal name='AccountPresence'> - <arg type='av' /> - </signal> - <signal name='ContactPresence'> - <arg type='av' /> - </signal> - <signal name='GCMessage'> - <arg type='av' /> - </signal> - <signal name='MessageSent'> - <arg type='av' /> - </signal> - <signal name='NewMessage'> - <arg type='av' /> - </signal> - <signal name='Subscribe'> - <arg type='av' /> - </signal> - <signal name='Subscribed'> - <arg type='av' /> - </signal> - <signal name='Unsubscribed'> - <arg type='av' /> - </signal> - </interface> - </node> - ''' - - def __init__(self): - self.con = Gio.bus_get_sync(Gio.BusType.SESSION, None) - Gio.bus_own_name_on_connection(self.con, 'org.gajim.Gajim', - Gio.BusNameOwnerFlags.NONE, None, None) - super().__init__(self.con, '/org/gajim/dbus/RemoteObject') - self.first_show = True - - app.ged.register_event_handler('presence-received', ged.POSTGUI, - self.on_presence_received) - app.ged.register_event_handler('subscribe-presence-received', - ged.POSTGUI, self.on_subscribe_presence_received) - app.ged.register_event_handler('subscribed-presence-received', - ged.POSTGUI, self.on_subscribed_presence_received) - app.ged.register_event_handler('unsubscribed-presence-received', - ged.POSTGUI, self.on_unsubscribed_presence_received) - app.ged.register_event_handler('gc-message-received', - ged.POSTGUI, self.on_gc_message_received) - app.ged.register_event_handler('decrypted-message-received', - ged.POSTGUI, self._nec_decrypted_message_received) - app.ged.register_event_handler('our-show', ged.POSTGUI, - self.on_our_status) - app.ged.register_event_handler('message-sent', ged.POSTGUI, - self.on_message_sent) - - def on_message_sent(self, obj): - try: - chatstate = obj.chatstate - except AttributeError: - chatstate = '' - self.raise_signal('MessageSent', (obj.account, [ - obj.jid, obj.message, chatstate])) - - def on_presence_received(self, event: events.PresenceReceived) -> None: - self.raise_signal('ContactPresence', (event.account, [ - event.jid, - event.resource, - event.show, - event.status])) - - def on_subscribe_presence_received(self, obj): - self.raise_signal('Subscribe', (obj.conn.name, [obj.jid, obj.status, - obj.user_nick])) - - def on_subscribed_presence_received(self, event): - self.raise_signal('Subscribed', (event.account, - [event.jid.bare, - event.jid.resource])) - - def on_unsubscribed_presence_received(self, obj): - self.raise_signal('Unsubscribed', (obj.conn.name, obj.jid)) - - def on_gc_message_received(self, obj): - if not hasattr(obj, 'needs_highlight'): - # TODO: - # event has not been handled at GUI level - return - self.raise_signal('GCMessage', (obj.conn.name, [obj.fjid, obj.msgtxt, - obj.properties.timestamp, obj.delayed, - obj.displaymarking, obj.needs_highlight])) - - def _nec_decrypted_message_received(self, obj): - event_type = obj.properties.type.value - if obj.properties.is_muc_pm: - event_type = 'pm' - self.raise_signal('NewMessage', ( - obj.conn.name, [obj.fjid, obj.msgtxt, obj.properties.timestamp, - event_type, obj.properties.subject, - obj.msg_log_id, obj.properties.nickname])) - - def on_our_status(self, event): - self.raise_signal('AccountPresence', (event.show, event.account)) - - def raise_signal(self, event_name: str, data: Any) -> None: - log.info('Send event %s', event_name) - self.con.emit_signal(None, - '/org/gajim/dbus/RemoteObject', - 'org.gajim.dbus.RemoteInterface', - event_name, - GLib.Variant.new_tuple(get_dbus_struct(data))) - - def get_status(self, account): - """ - Return status (show to be exact) which is the global one unless - account is given - """ - if not account: - # If user did not ask for account, returns the global status - return helpers.get_global_show() - # return show for the given account - return app.connections[account].status - - def get_status_message(self, account): - """ - Return status which is the global one unless account is given - """ - if not account: - # If user did not ask for account, returns the global status - return str(helpers.get_global_status_message()) - # return show for the given account - return app.connections[account].status_message - - def _get_account_and_contact(self, account, jid): - """ - Get the account (if not given) and contact instance from jid - """ - connected_account = None - contact = None - accounts = app.settings.get_active_accounts() - # if there is only one account in roster, take it as default - # if user did not ask for account - if not account and len(accounts) == 1: - account = accounts[0] - if account: - if app.account_is_available(account): # account is connected - connected_account = account - client = app.get_client(account) - contact = client.get_module('Contacts').get_contact(jid) - else: - for account_ in accounts: - client = app.get_client(account_) - contact = client.get_module('Contacts').get_contact(jid) - if app.account_is_available(account_): - # account is connected - connected_account = account_ - break - - return connected_account, contact - - def _get_account_for_groupchat(self, account, room_jid): - """ - Get the account which is connected to groupchat (if not given) - or check if the given account is connected to the groupchat - """ - connected_account = None - accounts = app.settings.get_active_accounts() - # if there is only one account in roster, take it as default - # if user did not ask for account - if not account and len(accounts) == 1: - account = accounts[0] - if account: - if app.account_is_available(account) and \ - room_jid in app.gc_connected[account] and \ - app.gc_connected[account][room_jid]: - # account and groupchat are connected - connected_account = account - else: - for account_ in accounts: - if app.account_is_available(account_) and \ - room_jid in app.gc_connected[account_] and \ - app.gc_connected[account_][room_jid]: - # account and groupchat are connected - connected_account = account_ - break - return connected_account - - def send_file(self, file_path, jid, account): - """ - Send file, located at 'file_path' to 'jid', using account (optional) - 'account' - """ - jid = self._get_real_jid(jid, account) - connected_account, contact = self._get_account_and_contact( - account, jid) - - if connected_account: - if file_path.startswith('file://'): - file_path = file_path[7:] - if os.path.isfile(file_path): # is it file? - app.interface.instances['file_transfers'].send_file( - connected_account, contact, file_path) - return True - return False - - def _send_message(self, - jid, - message, - account, - type_='chat', - subject=None): - """ - Can be called from send_chat_message (default when send_message) or - send_single_message - """ - if not jid or not message: - return False - - connected_account, contact = self._get_account_and_contact(account, jid) - if not connected_account or contact is None: - return False - - client = app.get_client(connected_account) - control = app.window.get_control(connected_account, jid) - if control is not None: - control.send_message(message) - else: - message_ = OutgoingMessage(account=connected_account, - contact=contact, - message=message, - type_=type_, - subject=subject, - control=control) - client.send_message(message_) - return True - - def send_chat_message(self, jid, message, account): - """ - Send chat 'message' to 'jid', using account (optional) 'account'. - """ - jid = self._get_real_jid(jid, account) - return self._send_message(jid, message, account) - - def send_single_message(self, jid, subject, message, account): - """ - Send single 'message' to 'jid', using account (optional) 'account'. - """ - jid = self._get_real_jid(jid, account) - return self._send_message(jid, message, account, 'normal', subject) - - def send_groupchat_message(self, room_jid, message, account): - """ - Send 'message' to groupchat 'room_jid', - using account (optional) 'account' - """ - if not room_jid or not message: - return False - connected_account = self._get_account_for_groupchat(account, room_jid) - if not connected_account: - return False - - client = app.get_client(connected_account) - contact = client.get_module('Contacts').get_contact( - connected_account, room_jid, groupchat=True) - - if not contact.is_joined: - return False - - message_ = OutgoingMessage(account=connected_account, - contact=contact, - message=message, - type_='groupchat') - client.send_message(message_) - return True - - def open_chat(self, jid, account, message): - """ - Shows the tabbed window for new message to 'jid', using account - 'account' (optional) - """ - if not jid: - raise ValueError('jid is missing') - jid = self._get_real_jid(jid, account) - try: - jid = helpers.parse_jid(jid) - except Exception: - # Jid is not conform, ignore it - return False - - if account: - accounts = [account] - else: - accounts = app.connections.keys() - if len(accounts) == 1: - account = accounts[0] - connected_account = None - first_connected_acct = None - for acct in accounts: - if app.account_is_available(acct): # account is online - client = app.get_client(acct) - contact = client.get_module('Contacts').get_contact(jid) - control = app.window.get_control(acct, jid) - if control is not None: - connected_account = acct - break - # jid is in roster - if contact.is_in_roster: - connected_account = acct - break - # we send the message to jid not in roster, because account is - # specified, or there is only one account - if account: - connected_account = acct - elif first_connected_acct is None: - first_connected_acct = acct - - # if jid is not a contact, open-chat with first connected account - if connected_account is None and first_connected_acct: - connected_account = first_connected_acct - - if connected_account: - app.interface.start_chat_from_jid(connected_account, jid, message) - # preserve the 'steal focus preservation' - if app.window.get_property('visible'): - app.window.present() - return True - return False - - def change_status(self, status, message, account): - """ - change_status(status, message, account). Account is optional - if not - specified status is changed for all accounts - """ - if status not in ('offline', 'online', 'chat', 'away', 'xa', 'dnd'): - status = '' - if account: - if not status: - if account not in app.connections: - return False - status = app.connections[account].status - GLib.idle_add(app.connections[account].change_status, status, - message) - else: - # account not specified, so change the status of all accounts - for acc in app.settings.get_active_accounts(): - if not app.settings.get_account_setting( - acc, 'sync_with_global_status'): - continue - if status: - status_ = status - else: - if acc not in app.connections: - continue - status_ = app.connections[acc].status - GLib.idle_add(app.connections[acc].change_status, status_, - message) - return False - - def set_priority(self, prio, account): - """ - set_priority(prio, account). Account is optional - if not specified - priority is changed for all accounts. That are synced with global status - """ - if account: - app.settings.set_account_setting(account, 'priority', prio) - show = app.connections[account].status - status = app.connections[account].status_message - GLib.idle_add(app.connections[account].change_status, show, status) - else: - # account not specified, so change prio of all accounts - for acc in app.settings.get_active_accounts(): - if not app.account_is_available(acc): - continue - if not app.settings.get_account_setting( - acc, 'sync_with_global_status'): - continue - app.settings.set_account_setting(acc, 'priority', prio) - show = app.connections[acc].status - status = app.connections[acc].status_message - GLib.idle_add(app.connections[acc].change_status, show, status) - - def list_accounts(self): - """ - List register accounts - """ - result = app.settings.get_active_accounts() - result_array = [] - if result: - for account in result: - result_array.append(account) - return result_array - - def account_info(self, account): - """ - Show info on account: resource, jid, nick, prio, message - """ - result = {} - if account in app.connections: - # account is valid - con = app.connections[account] - result['status'] = con.status - result['name'] = con.name - result['jid'] = app.get_jid_from_account(con.name) - result['message'] = con.status_message - result['priority'] = str(con.priority) - result['resource'] = app.settings.get_account_setting(con.name, - 'resource') - return result - - def list_contacts(self, account): - """ - List all contacts in the roster. If the first argument is specified, - then return the contacts for the specified account - """ - result = [] - accounts = app.settings.get_active_accounts() - if not accounts: - return result - if account: - accounts_to_search = [account] - else: - accounts_to_search = accounts - for acct in accounts_to_search: - if acct in accounts: - client = app.get_client(acct) - for contact in client.get_module('Roster').iter_contacts(): - item = self._contacts_as_dbus_structure(contact) - if item: - result.append(item) - return result - - def add_contact(self, jid, account): - if account: - if app.account_is_available(account): - # if given account is active, use it - AddContact(account=account, jid=jid) - else: - # wrong account - return False - else: - # if account is not given, show account combobox - AddContact(account=None, jid=jid) - return True - - def remove_contact(self, jid, account): - jid = self._get_real_jid(jid, account) - accounts = app.settings.get_active_accounts() - - # if there is only one account in roster, take it as default - if account: - accounts = [account] - contact_exists = False - for account_ in accounts: - client = app.get_client(account_) - contact = client.get_module('Contacts').get_contact(jid) - if contact.is_in_roster: - client.get_module('Presence').unsubscribe(jid) - client.get_module('Roster').delete_item(jid) - contact_exists = True - return contact_exists - - def _is_first(self): - if self.first_show: - self.first_show = False - return True - return False - - def _get_real_jid(self, jid, account=None): - """ - Get the real jid from the given one: removes xmpp: or get jid from nick - if account is specified, search only in this account - """ - if account: - accounts = [account] - else: - accounts = app.connections.keys() - if jid.startswith('xmpp:'): - return jid[5:] # len('xmpp:') = 5 - for account_ in accounts: - # Does jid exists in roster of one account ? - client = app.get_client(account_) - contact = client.get_module('Contacts').get_contact(jid) - if contact.is_pm_contact: - return contact.real_jid - return jid - - def _contacts_as_dbus_structure(self, contact: BareContact): - """ - Get info from list of Contact objects and create dbus dict - """ - - contact_dict = {} - - contact_dict['name'] = GLib.Variant('s', contact.name) - contact_dict['show'] = GLib.Variant('s', contact.show.value) - contact_dict['jid'] = GLib.Variant('s', str(contact.jid)) - - resources = GLib.VariantBuilder(GLib.VariantType('a(ss)')) - for res_contact in contact.iter_resources(): - resource_props = (res_contact.resource, - res_contact.status) - resources.add_value(GLib.Variant('(ss)', resource_props)) - contact_dict['resources'] = resources.end() - - groups = GLib.VariantBuilder(GLib.VariantType('as')) - for group in contact.groups: - groups.add_value(GLib.Variant('s', group)) - contact_dict['groups'] = groups.end() - return contact_dict - - def get_unread_msgs_number(self): - return str(app.window.get_total_unread_count()) - - def send_xml(self, xml, account): - if account: - app.connections[account].send_stanza(str(xml)) - else: - for acc in app.settings.get_active_accounts(): - app.connections[acc].send_stanza(str(xml)) - - def join_room(self, room_jid, password, account): - if not account: - # get the first connected account - accounts = app.connections.keys() - for acct in accounts: - if app.account_is_available(acct): - account = acct - break - if not account: - return - - app.interface.show_add_join_groupchat(account, - room_jid, - password=password) - - def Introspect(self): - return self.__doc__ View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/7e24d615a37caf81f3d41b4dbea2694d…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/7e24d615a37caf81f3d41b4dbea2694d…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] chore: Fix codestyle errors
by Philipp Hörist (ï¼ lovetox)
16 Jun '22
16 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: b32e35af by lovetox at 2022-06-16T16:20:44+02:00 chore: Fix codestyle errors - - - - - 2 changed files: - gajim/common/jingle_xtls.py - setup.cfg Changes: ===================================== gajim/common/jingle_xtls.py ===================================== @@ -25,18 +25,22 @@ log = logging.getLogger('gajim.c.jingle_xtls') -# key-exchange id -> [callback, args], accept that session once key-exchange completes +# key-exchange id -> [callback, args] +# accept that session once key-exchange completes pending_contents = {} + def key_exchange_pend(id_, cb, args): # args is a list pending_contents[id_] = [cb, args] + def approve_pending_content(id_): cb = pending_contents[id_][0] args = pending_contents[id_][1] cb(*args) + TYPE_RSA = crypto.TYPE_RSA TYPE_DSA = crypto.TYPE_DSA @@ -44,10 +48,12 @@ def approve_pending_content(id_): DH_PARAMS = 'dh_params.pem' DEFAULT_DH_PARAMS = 'dh4096.pem' + def default_callback(connection, certificate, error_num, depth, return_code): log.info("certificate: %s", certificate) return return_code + def load_cert_file(cert_path, cert_store=None): """ This is almost identical to the one in nbxmpp.tls_nb @@ -67,7 +73,7 @@ def load_cert_file(cert_path, cert_store=None): if 'BEGIN CERTIFICATE' in line: begin = i elif 'END CERTIFICATE' in line and begin > -1: - cert = ''.join(lines[begin:i+2]) + cert = ''.join(lines[begin:i + 2]) try: x509cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert) if cert_store: @@ -84,25 +90,27 @@ def load_cert_file(cert_path, cert_store=None): i += 1 f.close() + def get_context(fingerprint, verify_cb=None, remote_jid=None): """ constructs and returns the context objects """ ctx = SSL.Context(SSL.SSLv23_METHOD) - flags = (SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3 | SSL.OP_SINGLE_DH_USE \ - | SSL.OP_NO_TICKET) + flags = (SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3 | SSL.OP_SINGLE_DH_USE | + SSL.OP_NO_TICKET) ctx.set_options(flags) ctx.set_cipher_list(b'HIGH:!aNULL:!3DES') - if fingerprint == 'server': # for testing purposes only - ctx.set_verify(SSL.VERIFY_NONE|SSL.VERIFY_FAIL_IF_NO_PEER_CERT, + if fingerprint == 'server': # for testing purposes only + ctx.set_verify(SSL.VERIFY_NONE | SSL.VERIFY_FAIL_IF_NO_PEER_CERT, verify_cb or default_callback) elif fingerprint == 'client': ctx.set_verify(SSL.VERIFY_PEER, verify_cb or default_callback) cert_name = configpaths.get('MY_CERT') / SELF_SIGNED_CERTIFICATE ctx.use_privatekey_file(str(cert_name.with_suffix('.pkey')).encode('utf-8')) - ctx.use_certificate_file(str(cert_name.with_suffix('.cert')).encode('utf-8')) + ctx.use_certificate_file( + str(cert_name.with_suffix('.cert')).encode('utf-8')) # Try to load Diffie-Hellman parameters. # First try user DH parameters, if this fails load the default DH parameters @@ -110,7 +118,7 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None): try: with open(dh_params_name, "r", encoding='utf8'): ctx.load_tmp_dh(dh_params_name.encode('utf-8')) - except FileNotFoundError as err: + except FileNotFoundError: default_dh_params_name = (configpaths.get('DATA') / 'other' / DEFAULT_DH_PARAMS) try: @@ -123,14 +131,15 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None): if remote_jid: store = ctx.get_cert_store() - path = configpaths.get('MY_PEER_CERTS').expanduser() / (remote_jid - + '.cert') + path = configpaths.get('MY_PEER_CERTS').expanduser() + path = path / f'{remote_jid}.cert' if path.exists(): load_cert_file(path, cert_store=store) log.debug('certificate file %s loaded fingerprint %s', path, fingerprint) return ctx + def read_cert(certpath): certificate = '' with open(certpath, 'r', encoding='utf8') as certfile: @@ -139,9 +148,9 @@ def read_cert(certpath): certificate += line return certificate + def send_cert(con, jid_from, sid): - certpath = configpaths.get('MY_CERT') / (SELF_SIGNED_CERTIFICATE - + '.cert') + certpath = configpaths.get('MY_CERT') / f'{SELF_SIGNED_CERTIFICATE}.cert' certificate = read_cert(certpath) iq = nbxmpp.Iq('result', to=jid_from) iq.setAttr('id', sid) @@ -157,6 +166,7 @@ def send_cert(con, jid_from, sid): con.send(iq) + def handle_new_cert(con, obj, jid_from): jid = app.get_jid_without_resource(jid_from) certpath = configpaths.get('MY_PEER_CERTS').expanduser() / (jid + '.cert') @@ -175,17 +185,19 @@ def handle_new_cert(con, obj, jid_from): approve_pending_content(id_) + def check_cert(jid, fingerprint): certpath = configpaths.get('MY_PEER_CERTS').expanduser() / (jid + '.cert') if certpath.exists(): cert = load_cert_file(certpath) if cert: - digest_algo = cert.get_signature_algorithm().decode('utf-8')\ - .split('With')[0] + digest_algo = cert.get_signature_algorithm() + digest_algo = digest_algo.decode('utf-8').split('With')[0] if cert.digest(digest_algo) == fingerprint: return True return False + def send_cert_request(con, to_jid): iq = nbxmpp.Iq('get', to=to_jid) id_ = generate_id() @@ -197,6 +209,7 @@ def send_cert_request(con, to_jid): # the following code is partly due to pyopenssl examples + def createKeyPair(type_, bits): """ Create a public/private key pair. @@ -209,6 +222,7 @@ def createKeyPair(type_, bits): pkey.generate_key(type_, bits) return pkey + def createCertRequest(pkey, digest="sha256", **name): """ Create a certificate request. @@ -236,7 +250,9 @@ def createCertRequest(pkey, digest="sha256", **name): req.sign(pkey, digest) return req -def createCertificate(req, issuerCert, issuerKey, serial, notBefore, notAfter, digest="sha256"): + +def createCertificate(req, issuerCert, issuerKey, serial, notBefore, notAfter, + digest="sha256"): """ Generate a certificate given a certificate request. @@ -261,6 +277,7 @@ def createCertificate(req, issuerCert, issuerKey, serial, notBefore, notAfter, d cert.sign(issuerKey, digest) return cert + def make_certs(filepath, CN): """ make self signed certificates @@ -270,7 +287,8 @@ def make_certs(filepath, CN): """ key = createKeyPair(TYPE_RSA, 4096) req = createCertRequest(key, CN=CN) - cert = createCertificate(req, req, key, 0, 0, 60*60*24*365*5) # five years + # five years + cert = createCertificate(req, req, key, 0, 0, 60 * 60 * 24 * 365 * 5) with open(filepath.with_suffix('.pkey'), 'wb') as f: filepath.with_suffix('.pkey').chmod(0o600) f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, key)) ===================================== setup.cfg ===================================== @@ -8,9 +8,8 @@ exclude = test, typings gajim/command_system, - gajim/gajim_remote.py, - gajim/remote_control.py, gajim/common/config.py + gajim/common/optparser.py max-complexity = 15 builtins=_ max-line-length = 80 View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/b32e35af5a027c79dfdd37339b623daf…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/b32e35af5a027c79dfdd37339b623daf…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: refactor: Remove dead code
by Philipp Hörist (ï¼ lovetox)
16 Jun '22
16 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: ede6ad92 by lovetox at 2022-06-16T16:12:10+02:00 refactor: Remove dead code - - - - - 93b7eb22 by lovetox at 2022-06-16T16:12:10+02:00 chore: Fix codestyle errors - - - - - 4 changed files: - gajim/common/modules/bytestream.py - gajim/common/modules/message.py - gajim/common/storage/base.py - setup.cfg Changes: ===================================== gajim/common/modules/bytestream.py ===================================== @@ -63,6 +63,7 @@ def is_transfer_paused(file_props: FileProp) -> bool: return False return file_props.paused + def is_transfer_active(file_props: FileProp) -> bool: if file_props.stopped: return False @@ -74,6 +75,7 @@ def is_transfer_active(file_props: FileProp) -> bool: return True return not file_props.paused + def is_transfer_stopped(file_props: FileProp) -> bool: if not file_props: return True @@ -378,16 +380,18 @@ def ip_is_local(ip: str) -> bool: # it's an IPv6 return True ip_s = ip.split('.') - ip_l = int(ip_s[0])<<24 | int(ip_s[1])<<16 | int(ip_s[2])<<8 | \ - int(ip_s[3]) + ip_l = (int(ip_s[0]) << 24 | + int(ip_s[1]) << 16 | + int(ip_s[2]) << 8 | + int(ip_s[3])) # 10/8 - if ip_l & (255<<24) == 10<<24: + if ip_l & (255 << 24) == 10 << 24: return True # 172.16/12 - if ip_l & (255<<24 | 240<<16) == (172<<24 | 16<<16): + if ip_l & (255 << 24 | 240 << 16) == (172 << 24 | 16 << 16): return True # 192.168 - if ip_l & (255<<24 | 255<<16) == (192<<24 | 168<<16): + if ip_l & (255 << 24 | 255 << 16) == (192 << 24 | 168 << 16): return True return False @@ -446,7 +450,6 @@ def no_upnp_reply() -> bool: cleanup_gupnp() return False - self.ok_id = app.gupnp_igd.connect('mapped-external-port', success) self.fail_id = app.gupnp_igd.connect('error-mapping-port', fail) @@ -628,7 +631,7 @@ def _on_bytestream_set(self, streamhosts.append(host_dict) file_props = FilesProp.getFilePropBySid(sid) if file_props is not None: - if file_props.type_ == 's': # FIXME: remove fast xmlns + if file_props.type_ == 's': # FIXME: remove fast xmlns # only psi do this if file_props.streamhosts: file_props.streamhosts.extend(streamhosts) @@ -646,6 +649,7 @@ def _on_bytestream_set(self, raise nbxmpp.NodeProcessed file_props.streamhosts = streamhosts + def _connection_error(sid: str) -> None: self._connect_error(sid, 'item-not-found', @@ -693,7 +697,7 @@ def _on_bytestream_result(self, try: streamhost = query.getTag('streamhost-used') - except Exception: # this bytestream result is not what we need + except Exception: # this bytestream result is not what we need pass id_ = real_id[3:] file_props = FilesProp.getFileProp(self._account, id_) @@ -704,11 +708,11 @@ def _on_bytestream_result(self, if real_id.startswith('au_'): if file_props.streamhost_used is False: raise nbxmpp.NodeProcessed - if not file_props.proxyhosts: + if not file_props.proxyhosts: raise nbxmpp.NodeProcessed for host in file_props.proxyhosts: - if host['initiator'] == frm and \ - query.getAttr('sid') == file_props.sid: + if (host['initiator'] == frm and + query.getAttr('sid') == file_props.sid): app.socks5queue.activate_proxy(host['idx']) break raise nbxmpp.NodeProcessed ===================================== gajim/common/modules/message.py ===================================== @@ -152,22 +152,6 @@ def _message_received(self, msgtxt = properties.body session = None - # if not properties.type.is_groupchat: - # if properties.is_muc_pm and properties.type.is_error: - # session = self._con.find_session(fjid, properties.thread) - # if not session: - # session = self._con.get_latest_session(fjid) - # if not session: - # session = self._con.make_new_session( - # fjid, properties.thread, type_='pm') - # else: - # session = self._con.get_or_create_session( - # fjid, properties.thread) - - # if properties.thread and not session.received_thread_id: - # session.received_thread_id = True - - # session.last_receive = time.time() additional_data = AdditionalDataDict() @@ -208,12 +192,11 @@ def _message_received(self, correct_id = parse_correction(properties) if correct_id is not None: - event = MessageUpdated( - account=self._account, - jid=event_attr['jid'], - msgtxt=msgtxt, - properties=properties, - correct_id=correct_id) + event = MessageUpdated(account=self._account, + jid=event_attr['jid'], + msgtxt=msgtxt, + properties=properties, + correct_id=correct_id) app.storage.archive.store_message_correction( self._account, ===================================== gajim/common/storage/base.py ===================================== @@ -38,6 +38,7 @@ _T = TypeVar('_T') + def timeit(func: Callable[..., _T]) -> Callable[..., _T]: def func_wrapper(self: Any, *args: Any, **kwargs: Any) -> _T: start = time.time() @@ -55,9 +56,11 @@ def func_wrapper(self: Any, *args: Any, **kwargs: Any) -> _T: def _convert_common_error(common_error: bytes) -> CommonError: return CommonError.from_string(common_error) + def _adapt_common_error(common_error: CommonError) -> str: return common_error.serialize() + sqlite3.register_converter('common_error', _convert_common_error) sqlite3.register_adapter(CommonError, _adapt_common_error) @@ -68,21 +71,27 @@ def _convert_marker(marker: bytes): sqlite3.register_converter('marker', _convert_marker) + def _jid_adapter(jid: JID) -> str: return str(jid) + def _jid_converter(jid: bytes) -> JID: return JID.from_string(jid.decode()) + sqlite3.register_converter('jid', _jid_converter) sqlite3.register_adapter(JID, _jid_adapter) + def _convert_disco_info(disco_info: bytes) -> DiscoInfo: return parse_disco_info(Iq(node=disco_info)) # type: ignore + def _adapt_disco_info(disco_info: DiscoInfo) -> str: return str(disco_info.stanza) + sqlite3.register_converter('disco_info', _convert_disco_info) sqlite3.register_adapter(DiscoInfo, _adapt_disco_info) ===================================== setup.cfg ===================================== @@ -1,5 +1,5 @@ [flake8] -ignore = W504 +ignore = W504, C901 exclude = __pycache__, build, View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/61fae3de28986cde47cafa0dd854495…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/61fae3de28986cde47cafa0dd854495…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: fix: NotificationManager: Make displaying an invitation more robust
by Daniel Brötzmann (ï¼ wurstsalat)
16 Jun '22
16 Jun '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: a1dacac5 by wurstsalat at 2022-06-16T14:43:59+02:00 fix: NotificationManager: Make displaying an invitation more robust - - - - - 61fae3de by wurstsalat at 2022-06-16T15:13:17+02:00 fix: Preview: Catch PIL errors while generating preview Fixes #10989 - - - - - 4 changed files: - gajim/common/preview.py - gajim/common/preview_helpers.py - gajim/gtk/notification_manager.py - gajim/gtk/preview.py Changes: ===================================== gajim/common/preview.py ===================================== @@ -150,6 +150,7 @@ def orig_exists(self) -> bool: def create_thumbnail(self, data: bytes) -> bool: self.thumbnail = create_thumbnail(data, self.size) if self.thumbnail is None: + self.info_message = _('Creating thumbnail failed') log.warning('Creating thumbnail failed for: %s', self.orig_path) return False return True @@ -342,8 +343,7 @@ def _on_orig_load_finished(self, preview.thumbnail, self._on_thumb_write_finished, preview) - else: - preview.update_widget() + preview.update_widget() @staticmethod def _on_thumb_load_finished(data: Optional[bytes], @@ -426,7 +426,7 @@ def _on_content_sniffed(self, return if file_size == 0: - log.info('File size is unknown (zero) for URL: \'%s\'', uri) + log.info('File size is unknown (zero) for URL: \'%s\'', uri) session.cancel_message(message, Soup.Status.CANCELLED) return @@ -434,7 +434,9 @@ def _on_content_sniffed(self, log.info( 'File size (%s) too big for URL: \'%s\'', file_size, uri) - if not force: + if force: + preview.info_message = None + else: session.cancel_message(message, Soup.Status.CANCELLED) preview.info_message = _('Automatic preview disabled ' '(file too big)') @@ -463,6 +465,8 @@ def _on_finished(self, preview.update_widget() return + preview.info_message = None + data = message.props.response_body_data.get_data() if data is None: return @@ -486,6 +490,8 @@ def _on_finished(self, preview.thumbnail, self._on_thumb_write_finished, preview) + else: + preview.update_widget() @staticmethod def _on_orig_write_finished(_result: bool, ===================================== gajim/common/preview_helpers.py ===================================== @@ -146,7 +146,7 @@ def extract_and_resize_frames(image: Image.Image, return frames, result -def create_thumbnail(data: bytes, size:int) -> Optional[bytes]: +def create_thumbnail(data: bytes, size: int) -> Optional[bytes]: thumbnail = create_thumbnail_with_pil(data, size) if thumbnail is not None: return thumbnail @@ -191,7 +191,7 @@ def create_thumbnail_with_pil(data: bytes, size: int) -> Optional[bytes]: output_file = BytesIO() try: image = Image.open(input_file) - except OSError as error: + except Exception as error: log.warning('making pil thumbnail failed: %s', error) log.warning('fallback to pixbuf') input_file.close() ===================================== gajim/gtk/notification_manager.py ===================================== @@ -236,21 +236,23 @@ def add_invitation_received(self, event: MucInvitation) -> None: self.add(new_row) self.update_unread_count() - if get_muc_context(event.muc) == 'public': - jid = event.from_ + jid = event.from_.bare + muc_context = get_muc_context(event.muc) + if (muc_context == 'private' and + not event.muc.bare_match(event.from_)): + contact = self._client.get_module('Contacts').get_contact(jid) + text = _('%(contact)s invited you to %(chat)s') % { + 'contact': contact.name, + 'chat': event.info.muc_name} else: - jid = event.from_.bare - contact = self._client.get_module('Contacts').get_contact(jid) - text = _('%(contact)s invited you to %(chat)s') % { - 'contact': contact.name, - 'chat': event.info.muc_name} + text = _('You have been invited to %s') % event.info.muc_name app.ged.raise_event( Notification(account=self._account, - jid=jid, - type='group-chat-invitation', - title=_('Group Chat Invitation'), - text=text)) + jid=jid, + type='group-chat-invitation', + title=_('Group Chat Invitation'), + text=text)) def add_invitation_declined(self, event: MucDecline) -> None: row = self._get_notification_row(str(event.muc)) @@ -394,10 +396,7 @@ def __init__(self, account: str, event: MucInvitation) -> None: self._event = event - if get_muc_context(event.muc) == 'public': - jid = event.from_ - else: - jid = event.from_.bare + jid = event.from_.bare image = self._generate_avatar_image(jid) self.grid.attach(image, 1, 1, 1, 2) @@ -406,10 +405,16 @@ def __init__(self, account: str, event: MucInvitation) -> None: title_label.get_style_context().add_class('bold') self.grid.attach(title_label, 2, 1, 1, 1) - contact = self._client.get_module('Contacts').get_contact(jid) - invitation_text = _('%(contact)s invited you to %(chat)s') % { - 'contact': contact.name, - 'chat': event.info.muc_name} + muc_context = get_muc_context(event.muc) + if (muc_context == 'private' and + not event.muc.bare_match(event.from_)): + contact = self._client.get_module('Contacts').get_contact(jid) + invitation_text = _('%(contact)s invited you to %(chat)s') % { + 'contact': contact.name, + 'chat': event.info.muc_name} + else: + invitation_text = _('You have been invited ' + 'to %s') % event.info.muc_name text_label = self._generate_label() text_label.set_text(invitation_text) text_label.set_tooltip_text(invitation_text) ===================================== gajim/gtk/preview.py ===================================== @@ -142,6 +142,11 @@ def update(self, preview: Preview, data: Optional[GdkPixbufType]) -> None: label.set_ellipsize(Pango.EllipsizeMode.END) label.set_max_width_chars(32) + if preview.info_message is not None: + self._ui.info_message.set_text(preview.info_message) + self._ui.info_message.set_tooltip_text(preview.info_message) + self._ui.info_message.show() + if preview.orig_exists(): self._ui.download_button.hide() self._ui.open_folder_button.show() @@ -155,11 +160,6 @@ def update(self, preview: Preview, data: Optional[GdkPixbufType]) -> None: self._ui.right_box.pack_end(audio_widget, False, True, 0) self._ui.right_box.reorder_child(audio_widget, 1) else: - if preview.info_message is not None: - self._ui.info_message.set_text(preview.info_message) - self._ui.info_message.set_tooltip_text(preview.info_message) - self._ui.info_message.show() - if preview.file_size == 0: self._ui.download_button.hide() self._ui.link_button.show() View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/e093e6566848d7a688aa7a4aafcd930…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/e093e6566848d7a688aa7a4aafcd930…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] chore: Update translations
by Philipp Hörist (ï¼ lovetox)
15 Jun '22
15 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: e093e656 by Weblate at 2022-06-15T23:57:29+02:00 chore: Update translations - - - - - 14 changed files: - po/be.po - po/be(a)latin.po - po/bg.po - po/br.po - po/ca.po - po/cs.po - po/da.po - po/de.po - po/el.po - po/en_GB.po - po/eo.po - po/es.po - po/eu.po - po/fr.po The diff was not included because it is too large. View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e093e6566848d7a688aa7a4aafcd9304…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e093e6566848d7a688aa7a4aafcd9304…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] fix: Remote: Don’t fail on list_contacts
by Philipp Hörist (ï¼ lovetox)
15 Jun '22
15 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: aeb80da8 by lovetox at 2022-06-15T23:50:57+02:00 fix: Remote: Don’t fail on list_contacts Fixes #10985 - - - - - 2 changed files: - gajim/gui_interface.py - gajim/remote_control.py Changes: ===================================== gajim/gui_interface.py ===================================== @@ -700,7 +700,8 @@ def remote_init(): from gajim import remote_control remote_control.GajimRemote() except Exception: - pass + log.exception('Failed to init remote control') + GLib.timeout_add_seconds(5, remote_init) ===================================== gajim/remote_control.py ===================================== @@ -35,6 +35,7 @@ from gajim.common import helpers from gajim.common import events from gajim.common.structs import OutgoingMessage +from gajim.common.modules.contacts import BareContact from gajim.gui.add_contact import AddContact @@ -689,31 +690,26 @@ def _get_real_jid(self, jid, account=None): return contact.real_jid return jid - def _contacts_as_dbus_structure(self, bare_contact): + def _contacts_as_dbus_structure(self, contact: BareContact): """ Get info from list of Contact objects and create dbus dict """ - prim_contact = None # primary contact - for res_contact in bare_contact: - if (prim_contact is None or - res_contact.priority > prim_contact.priority): - prim_contact = res_contact + contact_dict = {} - name = bare_contact.name - contact_dict['name'] = GLib.Variant('s', name) - contact_dict['show'] = GLib.Variant('s', prim_contact.show) - contact_dict['jid'] = GLib.Variant('s', prim_contact.jid) - - resources = GLib.VariantBuilder(GLib.VariantType('a(sis)')) - for res_contact in bare_contact: - resource_props = (res_contact.jid.resource, - int(res_contact.priority), + + contact_dict['name'] = GLib.Variant('s', contact.name) + contact_dict['show'] = GLib.Variant('s', contact.show.value) + contact_dict['jid'] = GLib.Variant('s', str(contact.jid)) + + resources = GLib.VariantBuilder(GLib.VariantType('a(ss)')) + for res_contact in contact.iter_resources(): + resource_props = (res_contact.resource, res_contact.status) - resources.add_value(GLib.Variant('(sis)', resource_props)) + resources.add_value(GLib.Variant('(ss)', resource_props)) contact_dict['resources'] = resources.end() groups = GLib.VariantBuilder(GLib.VariantType('as')) - for group in bare_contact.groups: + for group in contact.groups: groups.add_value(GLib.Variant('s', group)) contact_dict['groups'] = groups.end() return contact_dict View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/aeb80da81863079850d9bde7213858d6…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/aeb80da81863079850d9bde7213858d6…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] fix: Limit max quote recursion
by Philipp Hörist (ï¼ lovetox)
15 Jun '22
15 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 61852300 by lovetox at 2022-06-15T22:56:06+02:00 fix: Limit max quote recursion Fixes #10977 - - - - - 1 changed file: - gajim/common/styling.py Changes: ===================================== gajim/common/styling.py ===================================== @@ -54,6 +54,7 @@ SD = 0 SD_POS = 1 +MAX_QUOTE_LEVEL = 20 @dataclass @@ -116,6 +117,12 @@ class PlainBlock(Block): uris: list[BaseUri] = field(default_factory=list) emojis: list[Emoji] = field(default_factory=list) + @classmethod + def from_quote_match(cls, match: Match[str]) -> PlainBlock: + return cls(start=match.start(), + end=match.end(), + text=match.group('quote')) + @dataclass class PreBlock(Block): @@ -187,11 +194,11 @@ def find_byte_index(text: str, index: int): raise ValueError('index not in string: %s, %s' % (text, index)) -def process(text: Union[str, bytes], nested: bool = False) -> ParsingResult: +def process(text: Union[str, bytes], level: int = 0) -> ParsingResult: if isinstance(text, bytes): text = text.decode() - blocks = _parse_blocks(text, nested) + blocks = _parse_blocks(text, level) for block in blocks: if isinstance(block, PlainBlock): offset = 0 @@ -204,18 +211,18 @@ def process(text: Union[str, bytes], nested: bool = False) -> ParsingResult: offset_bytes += len(line.encode()) if isinstance(block, QuoteBlock): - result = process(block.unquote(), nested=True) + result = process(block.unquote(), level=level + 1) block.blocks = result.blocks return ParsingResult(text, blocks) -def _parse_blocks(text: str, nested: bool) -> list[Block]: +def _parse_blocks(text: str, level: int) -> list[Block]: blocks: list[Block] = [] text_len = len(text) last_end_pos = 0 - rx = BLOCK_NESTED_RX if nested else BLOCK_RX + rx = BLOCK_NESTED_RX if level > 0 else BLOCK_RX for match in rx.finditer(text): if match.start() != last_end_pos: @@ -228,7 +235,10 @@ def _parse_blocks(text: str, nested: bool) -> list[Block]: group_dict = match.groupdict() if group_dict.get('quote') is not None: - blocks.append(QuoteBlock.from_match(match)) + if level > MAX_QUOTE_LEVEL: + blocks.append(PlainBlock.from_quote_match(match)) + else: + blocks.append(QuoteBlock.from_match(match)) if group_dict.get('pre') is not None: blocks.append(PreBlock.from_match(match)) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/618523002f1ab6b6088534d7c867a823…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/618523002f1ab6b6088534d7c867a823…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] fix: Preview: Don’t fail on invalid IPV6 urls
by Philipp Hörist (ï¼ lovetox)
15 Jun '22
15 Jun '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: e3b5a1fe by lovetox at 2022-06-15T21:52:55+02:00 fix: Preview: Don’t fail on invalid IPV6 urls Fixes #10984 - - - - - 1 changed file: - gajim/common/preview.py Changes: ===================================== gajim/common/preview.py ===================================== @@ -253,7 +253,11 @@ def is_previewable(self, return False uri = text - urlparts = urlparse(uri) + try: + urlparts = urlparse(uri) + except Exception: + return False + if not self._accept_uri(urlparts, uri, additional_data): return False View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e3b5a1feda00319d71d2415036d92d0e…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e3b5a1feda00319d71d2415036d92d0e…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
← Newer
1
...
145
146
147
148
149
150
151
...
1764
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
Results per page:
10
25
50
100
200