Philipp Hörist pushed to branch master at gajim / gajim
Commits:
890846fc by Philipp Hörist at 2019-09-12T18:50:24Z
Show SSLError dialog for all errors
Fixes #9835
- - - - -
1 changed file:
- gajim/gtk/ssl_error_dialog.py
Changes:
=====================================
gajim/gtk/ssl_error_dialog.py
=====================================
@@ -102,5 +102,5 @@ class SSLErrorDialog(Gtk.ApplicationWindow):
f.write(self._server + '\n')
f.write(pem + '\n\n')
- self._con.process_ssl_errors()
self.destroy()
+ self._con.process_ssl_errors()
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/890846fc38aaf0a09d9219aa786a776bf2…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/890846fc38aaf0a09d9219aa786a776bf2…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
16046d7e by Andrey Gursky at 2019-09-11T15:17:47Z
ChatControlBase: fix autoscroll on keyboard shortcuts
The issue reported by concerto [1] is a regression since af312830ef42fdb7.
[1] https://conference.gajim.org:5281/muc_log/gajim/2019-09-10#df591057-8693-4e…
- - - - -
1 changed file:
- gajim/chat_control_base.py
Changes:
=====================================
gajim/chat_control_base.py
=====================================
@@ -698,6 +698,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
if event.keyval == Gdk.KEY_Page_Down or \
event.keyval == Gdk.KEY_Page_Up:
self.conv_textview.tv.event(event)
+ self._on_scroll(None, event.keyval)
return True
if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
if event.keyval == Gdk.KEY_Tab: # CTRL + TAB
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/16046d7e87bc8962e35a41dc38f7e56b10…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/16046d7e87bc8962e35a41dc38f7e56b10…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
a27a4003 by Daniel Brötzmann at 2019-09-07T15:09:32Z
Use Accept (and make it the default) for image pasting
- - - - -
d47bee03 by Daniel Brötzmann at 2019-09-07T15:10:23Z
Use Accept default button, adapt some text strings
- - - - -
07bb750d by Daniel Brötzmann at 2019-09-09T12:35:06Z
Fix handle_event_http_auth answers from NewConfirmationDialog
- - - - -
10 changed files:
- gajim/chat_control.py
- gajim/chat_control_base.py
- gajim/dialogs.py
- gajim/groupchat_control.py
- gajim/gtk/accounts.py
- gajim/gtk/filetransfer.py
- gajim/gui_interface.py
- gajim/history_manager.py
- gajim/message_window.py
- gajim/roster_window.py
Changes:
=====================================
gajim/chat_control.py
=====================================
@@ -1152,7 +1152,7 @@ class ChatControl(ChatControlBase):
[DialogButton.make('Cancel',
callback=lambda: on_no(self)),
DialogButton.make('Remove',
- text=_('Close'),
+ text=_('_Close'),
callback=lambda: on_yes(self))],
transient_for=self.parent_win.window).show()
return
=====================================
gajim/chat_control_base.py
=====================================
@@ -622,8 +622,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
'clipboard\'s image into the chat window?'),
_('_Do not ask me again'),
[DialogButton.make('Cancel'),
- DialogButton.make('OK',
+ DialogButton.make('Accept',
text=_('_Paste'),
+ is_default=True,
callback=self._paste_event_confirmed,
args=[image])]).show()
@@ -1167,12 +1168,12 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
NewConfirmationDialog(
_('Privacy'),
_('Warning'),
- _('If you send a file to <b>%s</b>, '
- 'your real JID will be revealed.' % gc_contact.name),
+ _('If you send a file to <b>%s</b>, your real XMPP '
+ 'address will be revealed.' % gc_contact.name),
[DialogButton.make('Cancel'),
DialogButton.make(
'OK',
- text=_('Continue'),
+ text=_('_Continue'),
callback=lambda: _on_ok(gc_contact))]).show()
return
_on_ok(gc_contact)
=====================================
gajim/dialogs.py
=====================================
@@ -667,11 +667,12 @@ class ChangeStatusMessageDialog(TimeoutDialog):
self.countdown_enabled = False
start_iter, finish_iter = self.message_buffer.get_bounds()
status_message_to_save_as_preset = self.message_buffer.get_text(
- start_iter, finish_iter, True)
+ start_iter, finish_iter, True)
+
def on_ok(msg_name):
msg_text = status_message_to_save_as_preset
msg_text_1l = helpers.to_one_line(msg_text)
- if not msg_name: # msg_name was ''
+ if not msg_name: # msg_name was ''
msg_name = msg_text_1l
def _on_ok2():
@@ -681,23 +682,23 @@ class ChangeStatusMessageDialog(TimeoutDialog):
self.pep_dict.get('activity_text'),
self.pep_dict.get('mood'), self.pep_dict.get('mood_text')]
app.config.set_per('statusmsg', msg_name, 'message',
- msg_text_1l)
+ msg_text_1l)
app.config.set_per('statusmsg', msg_name, 'activity',
- self.pep_dict.get('activity'))
+ self.pep_dict.get('activity'))
app.config.set_per('statusmsg', msg_name, 'subactivity',
- self.pep_dict.get('subactivity'))
+ self.pep_dict.get('subactivity'))
app.config.set_per('statusmsg', msg_name, 'activity_text',
- self.pep_dict.get('activity_text'))
+ self.pep_dict.get('activity_text'))
app.config.set_per('statusmsg', msg_name, 'mood',
- self.pep_dict.get('mood'))
+ self.pep_dict.get('mood'))
app.config.set_per('statusmsg', msg_name, 'mood_text',
- self.pep_dict.get('mood_text'))
+ self.pep_dict.get('mood_text'))
if msg_name in self.preset_messages_dict:
NewConfirmationDialog(
_('Overwrite'),
_('Overwrite Status Message?'),
- _('Preset name is already in use. '
- 'Do you want to overwrite this preset?'),
+ _('This name is already in use. Do you want to '
+ 'overwrite this preset?'),
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
text=_('_Overwrite'),
=====================================
gajim/groupchat_control.py
=====================================
@@ -64,7 +64,6 @@ from gajim.common import contacts
from gajim.common.const import StyleAttr
from gajim.common.const import Chatstate
from gajim.common.const import MUCJoinedState
-from gajim.common.const import ButtonAction
from gajim.chat_control_base import ChatControlBase
@@ -1174,9 +1173,8 @@ class GroupchatControl(ChatControlBase):
_('<b>%s</b> from <b>%s</b> requests voice') % (
event.voice_request.nick, self.room_name),
[DialogButton.make('Cancel'),
- DialogButton.make('OK',
- text=_('Approve'),
- action=ButtonAction.SUGGESTED,
+ DialogButton.make('Accept',
+ text=_('_Approve'),
callback=on_approve)],
modal=False).show()
@@ -2278,8 +2276,9 @@ class GroupchatControl(ChatControlBase):
_('_Do not ask me again'),
[DialogButton.make('Cancel',
callback=on_cancel),
- DialogButton.make('OK',
+ DialogButton.make('Accept',
text=_('_Leave'),
+ is_default=True,
callback=on_ok)],
transient_for=self.parent_win.window).show()
return
=====================================
gajim/gtk/accounts.py
=====================================
@@ -139,7 +139,7 @@ class AccountsWindow(Gtk.ApplicationWindow):
_('To apply all changes instantly, you have to re-login.'),
[DialogButton.make('Cancel',
text=_('_Later')),
- DialogButton.make('OK',
+ DialogButton.make('Accept',
text=_('_Re-Login'),
callback=lambda *args: relog(account))],
transient_for=self).show()
@@ -193,8 +193,7 @@ class AccountsWindow(Gtk.ApplicationWindow):
NewConfirmationDialog(
_('Remove Account'),
_('You still have open chats in your account %s') % account,
- _('All chat and group chat windows will be closed.\n'
- 'Do you want to continue?'),
+ _('All chat and group chat windows will be closed.'),
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
callback=remove)],
@@ -571,8 +570,7 @@ class AccountRow(Gtk.ListBoxRow):
NewConfirmationDialog(
_('Disable Account'),
_('Account %s is still connected') % account,
- _('All chat and group chat windows will be closed. '
- 'Do you want to continue?'),
+ _('All chat and group chat windows will be closed.'),
[DialogButton.make('Cancel',
callback=lambda: switch.set_active(True)),
DialogButton.make('Remove',
@@ -972,13 +970,13 @@ class RemoveAccountWindow:
else:
self._on_remove_success(True)
- if self.account in app.connections and \
- app.connections[self.account].connected:
+ if (self.account in app.connections and
+ app.connections[self.account].connected):
NewConfirmationDialog(
_('Remove Account'),
- _('Account \'%s\' is still connected to the '
- 'server') % self.account,
- _('If you remove it, the connection will be lost.'),
+ _('Still connected to the server'),
+ _('Account \'%s\' is still connected to the server. If you '
+ 'remove it, the connection will be lost.') % self.account,
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
callback=remove)],
=====================================
gajim/gtk/filetransfer.py
=====================================
@@ -336,7 +336,7 @@ class FileTransfersWindow:
'Do you want to download it again?') % file_name,
[DialogButton.make('Cancel',
text=_('_No')),
- DialogButton.make('OK',
+ DialogButton.make('Accept',
text=_('_Download Again'),
callback=on_yes,
args=[jid,
@@ -421,16 +421,17 @@ class FileTransfersWindow:
NewConfirmationDialog(
_('File Transfer Conflict'),
- _('This file already exists'),
+ _('File already exists'),
_('Resume download or replace file?'),
[DialogButton.make('Cancel',
callback=_on_cancel),
- DialogButton.make('OK',
- text=_('Replace _File'),
- callback=_on_replace),
DialogButton.make('OK',
text=_('Resume _Download'),
- callback=_on_resume)]).show()
+ callback=_on_resume),
+ DialogButton.make('Accept',
+ text=_('Replace _File'),
+ is_default=True,
+ callback=_on_replace)]).show()
# File does not exist yet
dirname = os.path.dirname(file_path)
@@ -486,8 +487,7 @@ class FileTransfersWindow:
sectext,
[DialogButton.make('Cancel',
callback=_on_cancel),
- DialogButton.make('OK',
- text=_('_Accept'),
+ DialogButton.make('Accept',
callback=_on_ok)]).show()
def set_status(self, file_props, status):
=====================================
gajim/gui_interface.py
=====================================
@@ -167,7 +167,7 @@ class Interface:
obj.stanza, answer)
account = obj.conn.name
- pri_msg = _('HTTP (%(method)s) Authorization '
+ message = _('HTTP (%(method)s) Authorization '
'for %(url)s (ID: %(id)s)') % {
'method': obj.method,
'url': obj.url,
@@ -177,19 +177,19 @@ class Interface:
sec_msg = _('Do you accept this request (account: %s)?') % account
if obj.msg:
sec_msg = obj.msg + '\n' + sec_msg
+ message = message + '\n' + sec_msg
NewConfirmationDialog(
- _('Authorization'),
- pri_msg,
- sec_msg,
+ _('Authorization Request'),
+ _('HTTP Authorization Request'),
+ message,
[DialogButton.make('Cancel',
text=_('_No'),
callback=_response,
- args=[obj, 'yes']),
- DialogButton.make('OK',
- text=_('_Accept'),
+ args=[obj, 'no']),
+ DialogButton.make('Accept',
callback=_response,
- args=[obj, 'no'])]).show()
+ args=[obj, 'yes'])]).show()
def handle_event_iq_error(self, event):
ctrl = self.msg_win_mgr.get_control(event.properties.jid.getBare(),
=====================================
gajim/history_manager.py
=====================================
@@ -245,9 +245,9 @@ class HistoryManager:
NewConfirmationDialog(
_('Database Cleanup'),
- _('Do you want to clean up the database? '
- '(STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING)'),
- _('Normally, the allocated database size will not be freed, it '
+ _('Clean up the database?'),
+ _('This is STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING.\n'
+ 'Normally, the allocated database size will not be freed, it '
'will just become reusable. This operation may take a while.'),
[DialogButton.make('Cancel',
callback=_on_no),
=====================================
gajim/message_window.py
=====================================
@@ -358,11 +358,13 @@ class MessageWindow:
NewConfirmationCheckDialog(
_('Close Tabs'),
- _('You are going to close several tabs'),
- _('Do you really want to close them all?'),
+ _('You are about to close several tabs'),
+ _('Do you really want to close all of them?'),
_('_Do not ask me again'),
[DialogButton.make('Cancel'),
- DialogButton.make('OK',
+ DialogButton.make('Accept',
+ text=_('_Close'),
+ is_default=True,
callback=_on_yes1)],
transient_for=self.window).show()
return True
=====================================
gajim/roster_window.py
=====================================
@@ -4125,8 +4125,9 @@ class RosterWindow:
sectext,
_('_Do not ask me again'),
[DialogButton.make('Cancel'),
- DialogButton.make('OK',
+ DialogButton.make('Accept',
text=_('_Create'),
+ is_default=True,
callback=merge_contacts)]).show()
def on_drop_in_group(self, widget, account, c_source, grp_dest,
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/5623dfbaf766e10ad76420a0d16c7c199…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/5623dfbaf766e10ad76420a0d16c7c199…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
2257da6c by Daniel Brötzmann at 2019-09-05T21:02:00Z
CommandSystem: Add setting to disable execution of commands by default
- - - - -
9f59eb54 by Daniel Brötzmann at 2019-09-05T21:02:00Z
CommandSystem: Fix some pylint errors
- - - - -
10 changed files:
- gajim/command_system/errors.py
- gajim/command_system/framework.py
- gajim/command_system/implementation/custom.py
- gajim/command_system/implementation/execute.py
- gajim/command_system/implementation/hosts.py
- gajim/command_system/implementation/middleware.py
- gajim/command_system/implementation/standard.py
- gajim/command_system/mapping.py
- gajim/command_system/tools.py
- gajim/common/config.py
Changes:
=====================================
gajim/command_system/errors.py
=====================================
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
class BaseError(Exception):
"""
Common base for errors which relate to a specific command.
@@ -34,16 +35,19 @@ class BaseError(Exception):
def __str__(self):
return self.message
+
class DefinitionError(BaseError):
"""
Used to indicate errors occurred on command definition.
"""
+
class CommandError(BaseError):
"""
Used to indicate errors occurred during command execution.
"""
+
class NoCommandError(BaseError):
"""
Used to indicate an inability to find the specified command.
=====================================
gajim/command_system/framework.py
=====================================
@@ -22,10 +22,16 @@ declarative way.
from types import FunctionType
from inspect import getargspec, getdoc
-from gajim.command_system.dispatcher import Host, Container
-from gajim.command_system.dispatcher import get_command, list_commands
-from gajim.command_system.mapping import parse_arguments, adapt_arguments
-from gajim.command_system.errors import DefinitionError, CommandError, NoCommandError
+from gajim.command_system.dispatcher import Host
+from gajim.command_system.dispatcher import Container
+from gajim.command_system.dispatcher import get_command
+from gajim.command_system.dispatcher import list_commands
+from gajim.command_system.mapping import parse_arguments
+from gajim.command_system.mapping import adapt_arguments
+from gajim.command_system.errors import DefinitionError
+from gajim.command_system.errors import CommandError
+from gajim.command_system.errors import NoCommandError
+
class CommandHost(metaclass=Host):
"""
@@ -39,6 +45,7 @@ class CommandHost(metaclass=Host):
"""
__metaclass__ = Host
+
class CommandContainer(metaclass=Container):
"""
Command container is an entity which holds defined commands,
@@ -55,6 +62,7 @@ class CommandContainer(metaclass=Container):
"""
__metaclass__ = Container
+
class CommandProcessor:
"""
Command processor is an immediate command emitter. It does not
@@ -142,6 +150,7 @@ class CommandProcessor:
commands = dict(commands)
return sorted(set(commands.values()), key=lambda k: k.__repr__())
+
class Command:
def __init__(self, handler, *names, **properties):
@@ -217,7 +226,8 @@ class Command:
# Behavior of this code need to be checked. Might yield
# incorrect results on some rare occasions.
spec_args = names[:-len(defaults) if defaults else len(names)]
- spec_kwargs = list(zip(names[-len(defaults):], defaults)) if defaults else {}
+ spec_kwargs = list(
+ zip(names[-len(defaults):], defaults)) if defaults else {}
# Removing self from arguments specification. Command handler
# should receive the processors as a first argument, which
@@ -227,6 +237,7 @@ class Command:
return spec_args, spec_kwargs, var_args, var_kwargs
+
def command(*names, **properties):
"""
A decorator for defining commands in a declarative way. Provides
@@ -287,7 +298,8 @@ def command(*names, **properties):
raise DefinitionError("Empty option can be used only with raw commands")
if extra and overlap:
- raise DefinitionError("Extra and overlap options can not be used together")
+ raise DefinitionError("Extra and overlap options can not be used "
+ "together")
properties = {
'usage': usage,
@@ -323,6 +335,7 @@ def command(*names, **properties):
return decorator
+
def doc(text):
"""
This decorator is used to bind a documentation (a help) to a
=====================================
gajim/command_system/implementation/custom.py
=====================================
@@ -35,8 +35,13 @@ detected.
"""
from gajim.common.i18n import _
-from gajim.command_system.framework import CommandContainer, command, doc
-from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
+from gajim.command_system.framework import CommandContainer
+from gajim.command_system.framework import command
+from gajim.command_system.framework import doc
+from gajim.command_system.implementation.hosts import ChatCommands
+from gajim.command_system.implementation.hosts import PrivateChatCommands
+from gajim.command_system.implementation.hosts import GroupChatCommands
+
class CustomCommonCommands(CommandContainer):
"""
@@ -69,6 +74,7 @@ class CustomCommonCommands(CommandContainer):
"""
return "I don't dance."
+
class CustomChatCommands(CommandContainer):
"""
This command container bounds only to the ChatCommands command host.
@@ -92,6 +98,7 @@ class CustomChatCommands(CommandContainer):
"""
return "Buy yourself a stereo."
+
class CustomPrivateChatCommands(CommandContainer):
"""
This command container bounds only to the PrivateChatCommands
@@ -108,6 +115,7 @@ class CustomPrivateChatCommands(CommandContainer):
def make_coffee(self):
return "I'm not a coffee machine!"
+
class CustomGroupChatCommands(CommandContainer):
"""
This command container bounds only to the GroupChatCommands command
=====================================
gajim/command_system/implementation/execute.py
=====================================
@@ -37,9 +37,15 @@ from os.path import expanduser
from gi.repository import GLib
+from gajim.common import app
from gajim.common.i18n import _
-from gajim.command_system.framework import CommandContainer, command, doc
-from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
+from gajim.command_system.framework import CommandContainer
+from gajim.command_system.framework import command
+from gajim.command_system.framework import doc
+from gajim.command_system.implementation.hosts import ChatCommands
+from gajim.command_system.implementation.hosts import PrivateChatCommands
+from gajim.command_system.implementation.hosts import GroupChatCommands
+
class Execute(CommandContainer):
AUTOMATIC = True
@@ -57,10 +63,18 @@ class Execute(CommandContainer):
@classmethod
def spawn(cls, processor, expression):
- pipes = dict(stdout=PIPE, stderr=PIPE)
- directory = expanduser(cls.DIRECTORY)
- popen = Popen(expression, shell=True, cwd=directory, **pipes)
- cls.monitor(processor, popen)
+ command_system_execute = app.config.get('command_system_execute')
+ if command_system_execute:
+ pipes = dict(stdout=PIPE, stderr=PIPE)
+ directory = expanduser(cls.DIRECTORY)
+ popen = Popen(expression, shell=True, cwd=directory, **pipes)
+ cls.monitor(processor, popen)
+ else:
+ processor.echo_error(
+ _('Command disabled. This command can be enabled by '
+ 'setting \'command_system_execute\' to True in ACE '
+ '(Advanced Configuration Editor).'))
+ return
@classmethod
def monitor(cls, processor, popen):
@@ -104,6 +118,7 @@ class Execute(CommandContainer):
strip = chr(10) + chr(32)
return text.decode().strip(strip)
+
class Show(Execute):
@command("sh", raw=True)
=====================================
gajim/command_system/implementation/hosts.py
=====================================
@@ -20,6 +20,7 @@ different command processors, which are the source of commands.
from gajim.command_system.framework import CommandHost
+
class ChatCommands(CommandHost):
"""
This command host is bound to the command processor which processes
@@ -27,6 +28,7 @@ class ChatCommands(CommandHost):
"""
AUTOMATIC = True
+
class PrivateChatCommands(CommandHost):
"""
This command host is bound to the command processor which processes
@@ -34,6 +36,7 @@ class PrivateChatCommands(CommandHost):
"""
AUTOMATIC = True
+
class GroupChatCommands(CommandHost):
"""
This command host is bound to the command processor which processes
=====================================
gajim/command_system/implementation/middleware.py
=====================================
@@ -39,7 +39,9 @@ from gajim.common import app
from gajim.common.i18n import _
from gajim.command_system.framework import CommandProcessor
-from gajim.command_system.errors import CommandError, NoCommandError
+from gajim.command_system.errors import CommandError
+from gajim.command_system.errors import NoCommandError
+
class ChatCommandProcessor(CommandProcessor):
"""
@@ -95,12 +97,14 @@ class ChatCommandProcessor(CommandProcessor):
self.echo(help_(self, name))
return True
- def command_postprocessor(self, command, name, arguments, args, kwargs, value):
+ def command_postprocessor(self, command, name, arguments, args, kwargs,
+ value):
# If command returns a string - print it to a user. A convenient
# and sufficient in most simple cases shortcut to a using echo.
if value and isinstance(value, str):
self.echo(value)
+
class CommandTools:
"""
Contains a set of basic tools and shortcuts you can use in your
=====================================
gajim/command_system/implementation/standard.py
=====================================
@@ -17,7 +17,8 @@
Provides an actual implementation for the standard commands.
"""
-from time import localtime, strftime
+from time import localtime
+from time import strftime
from datetime import date
from gi.repository import GLib
@@ -28,10 +29,14 @@ from gajim.common.i18n import _
from gajim.common.const import KindConstant
from gajim.command_system.errors import CommandError
-from gajim.command_system.framework import CommandContainer, command, doc
+from gajim.command_system.framework import CommandContainer
+from gajim.command_system.framework import command
+from gajim.command_system.framework import doc
from gajim.command_system.mapping import generate_usage
-from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
+from gajim.command_system.implementation.hosts import ChatCommands
+from gajim.command_system.implementation.hosts import PrivateChatCommands
+from gajim.command_system.implementation.hosts import GroupChatCommands
class StandardCommonCommands(CommandContainer):
@@ -44,7 +49,8 @@ class StandardCommonCommands(CommandContainer):
HOSTS = ChatCommands, PrivateChatCommands, GroupChatCommands
@command(overlap=True)
- @doc(_("Show help on a given command or a list of available commands if -a is given"))
+ @doc(_("Show help on a given command or a list of available commands if "
+ "-a is given"))
def help(self, cmd=None, all_=False):
if cmd:
cmd = self.get_command(cmd)
@@ -111,12 +117,13 @@ class StandardCommonCommands(CommandContainer):
if date_obj == date.today():
formatted = "[%s] %s: %s" % (time_, contact, row.message)
else:
- formatted = "[%s, %s] %s: %s" % (date_, time_, contact, row.message)
+ formatted = "[%s, %s] %s: %s" % (
+ date_, time_, contact, row.message)
self.echo(formatted)
@command(raw=True, empty=True)
- #Do not translate online, away, chat, xa, dnd
+ # Do not translate online, away, chat, xa, dnd
@doc(_("""
Set the current status
@@ -128,7 +135,7 @@ class StandardCommonCommands(CommandContainer):
raise CommandError("Invalid status given")
for connection in app.connections.values():
if not app.config.get_per('accounts', connection.name,
- 'sync_with_global_status'):
+ 'sync_with_global_status'):
continue
if not connection.is_connected:
continue
@@ -142,7 +149,7 @@ class StandardCommonCommands(CommandContainer):
for connection in app.connections.values():
if not app.config.get_per('accounts', connection.name,
- 'sync_with_global_status'):
+ 'sync_with_global_status'):
continue
if not connection.is_connected:
continue
@@ -156,12 +163,13 @@ class StandardCommonCommands(CommandContainer):
for connection in app.connections.values():
if not app.config.get_per('accounts', connection.name,
- 'sync_with_global_status'):
+ 'sync_with_global_status'):
continue
if not connection.is_connected:
continue
connection.change_status('online', message)
+
class StandardCommonChatCommands(CommandContainer):
"""
This command container contains standard commands, which are common
@@ -180,7 +188,8 @@ class StandardCommonChatCommands(CommandContainer):
@doc(_("Send a ping to the contact"))
def ping(self):
if self.account == app.ZEROCONF_ACC_NAME:
- raise CommandError(_('Command is not supported for zeroconf accounts'))
+ raise CommandError(
+ _('Command is not supported for zeroconf accounts'))
app.connections[self.account].get_module('Ping').send_ping(self.contact)
@command
@@ -221,6 +230,7 @@ class StandardCommonChatCommands(CommandContainer):
def attention(self, message):
self.send_message(message, process_commands=False, attention=True)
+
class StandardChatCommands(CommandContainer):
"""
This command container contains standard commands which are unique
@@ -230,6 +240,7 @@ class StandardChatCommands(CommandContainer):
AUTOMATIC = True
HOSTS = (ChatCommands,)
+
class StandardPrivateChatCommands(CommandContainer):
"""
This command container contains standard commands which are unique
@@ -239,6 +250,7 @@ class StandardPrivateChatCommands(CommandContainer):
AUTOMATIC = True
HOSTS = (PrivateChatCommands,)
+
class StandardGroupChatCommands(CommandContainer):
"""
This command container contains standard commands which are unique
@@ -275,7 +287,8 @@ class StandardGroupChatCommands(CommandContainer):
raise CommandError(_("Nickname not found"))
@command('msg', raw=True)
- @doc(_("Open a private chat window with a specified participant and send him a message"))
+ @doc(_("Open a private chat window with a specified participant and send "
+ "him a message"))
def message(self, nick, a_message):
nicks = app.contacts.get_nick_list(self.account, self.room_jid)
if nick in nicks:
@@ -296,7 +309,8 @@ class StandardGroupChatCommands(CommandContainer):
@doc(_("Invite a user to a group chat for a reason"))
def invite(self, jid, reason):
self.connection.get_module('MUC').invite(self.room_jid, jid, reason)
- return _("Invited %(jid)s to %(room_jid)s") % {'jid': jid,
+ return _("Invited %(jid)s to %(room_jid)s") % {
+ 'jid': jid,
'room_jid': self.room_jid}
@command(raw=True, empty=True)
@@ -310,7 +324,8 @@ class StandardGroupChatCommands(CommandContainer):
GLib.Variant('as', [self.account, jid]))
@command('part', 'close', raw=True, empty=True)
- @doc(_("Leave the group chat, optionally giving a reason, and close tab or window"))
+ @doc(_("Leave the group chat, optionally giving a reason, and close tab or "
+ "window"))
def leave(self, reason):
self.leave(reason=reason)
@@ -322,7 +337,8 @@ class StandardGroupChatCommands(CommandContainer):
"""))
def ban(self, who, reason=''):
if who in app.contacts.get_nick_list(self.account, self.room_jid):
- contact = app.contacts.get_gc_contact(self.account, self.room_jid, who)
+ contact = app.contacts.get_gc_contact(
+ self.account, self.room_jid, who)
who = contact.jid
self.connection.get_module('MUC').set_affiliation(
self.room_jid,
@@ -332,25 +348,25 @@ class StandardGroupChatCommands(CommandContainer):
@command(raw=True, empty=True)
@doc(_("Kick user from group chat by nickname"))
def kick(self, who, reason):
- if not who in app.contacts.get_nick_list(self.account, self.room_jid):
+ if who not in app.contacts.get_nick_list(self.account, self.room_jid):
raise CommandError(_("Nickname not found"))
self.connection.get_module('MUC').set_role(
self.room_jid, who, 'none', reason or str())
@command(raw=True)
- #Do not translate moderator, participant, visitor, none
+ # Do not translate moderator, participant, visitor, none
@doc(_("""Set participant role in group chat.
Role can be given as one of the following values:
moderator, participant, visitor, none"""))
def role(self, who, role):
if role not in ('moderator', 'participant', 'visitor', 'none'):
raise CommandError(_("Invalid role given"))
- if not who in app.contacts.get_nick_list(self.account, self.room_jid):
+ if who not in app.contacts.get_nick_list(self.account, self.room_jid):
raise CommandError(_("Nickname not found"))
self.connection.get_module('MUC').set_role(self.room_jid, who, role)
@command(raw=True)
- #Do not translate owner, admin, member, outcast, none
+ # Do not translate owner, admin, member, outcast, none
@doc(_("""Set participant affiliation in group chat.
Affiliation can be given as one of the following values:
owner, admin, member, outcast, none"""))
@@ -401,6 +417,7 @@ class StandardGroupChatCommands(CommandContainer):
@doc(_("Send a ping to the contact"))
def ping(self, nick):
if self.account == app.ZEROCONF_ACC_NAME:
- raise CommandError(_('Command is not supported for zeroconf accounts'))
+ raise CommandError(
+ _('Command is not supported for zeroconf accounts'))
gc_c = app.contacts.get_gc_contact(self.account, self.room_jid, nick)
app.connections[self.account].get_module('Ping').send_ping(gc_c)
=====================================
gajim/command_system/mapping.py
=====================================
@@ -27,7 +27,8 @@ from operator import itemgetter
from gajim.common.i18n import _
-from gajim.command_system.errors import DefinitionError, CommandError
+from gajim.command_system.errors import DefinitionError
+from gajim.command_system.errors import CommandError
# Quite complex piece of regular expression logic to parse options and
# arguments. Might need some tweaking along the way.
@@ -43,6 +44,7 @@ KEY_ENCODING = 'UTF-8'
# on command handler argument specification) will be rendered.
USAGE_PATTERN = 'Usage: %s %s'
+
def parse_arguments(arguments):
"""
Simple yet effective and sufficient in most cases parser which
@@ -110,6 +112,7 @@ def parse_arguments(arguments):
return args, opts
+
def adapt_arguments(command, arguments, args, opts):
"""
Adapt args and opts got from the parser to a specific handler by
@@ -268,7 +271,8 @@ def adapt_arguments(command, arguments, args, opts):
initial = norm_kwargs.get(key)
if isinstance(initial, bool):
if not isinstance(value, bool):
- raise CommandError("%s: Switch can not take an argument" % key, command)
+ raise CommandError(
+ "%s: Switch can not take an argument" % key, command)
# Inject the source arguments as a string as a first argument, if
# command has enabled the corresponding option.
@@ -279,6 +283,7 @@ def adapt_arguments(command, arguments, args, opts):
# command handler and being expanded.
return tuple(args), dict(opts)
+
def generate_usage(command, complete=True):
"""
Extract handler's arguments specification and wrap them in a
@@ -323,7 +328,8 @@ def generate_usage(command, complete=True):
if spec_args:
args += '<%s>' % ', '.join(spec_args)
if var_args or sp_extra:
- args += (' ' if spec_args else str()) + '<<%s>>' % (var_args or sp_extra)
+ args += (' ' if spec_args else str()) + '<<%s>>' % (
+ var_args or sp_extra)
usage += args
=====================================
gajim/command_system/tools.py
=====================================
@@ -24,6 +24,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
def remove(sequence, target):
if isinstance(sequence, list):
if target in sequence:
=====================================
gajim/common/config.py
=====================================
@@ -288,6 +288,7 @@ class Config:
'muclumbus_api_http_uri': [opt_str, 'https://search.jabbercat.org/api/1.0/search'],
'muclumbus_api_pref': [opt_str, 'http', _('API Preferences. Possible values: \'http\', \'iq\'')],
'auto_copy': [opt_bool, True, _('Selecting text will copy it to the clipboard')],
+ 'command_system_execute': [opt_bool, False, _('If enabled, Gajim will execute commands (/show, /sh, /execute, /exec).')],
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
__options_per_key = {
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/911aaa1f88552992788410210e9cfe34d…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/911aaa1f88552992788410210e9cfe34d…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
40520af1 by Philipp Hörist at 2019-09-05T20:07:53Z
Add public method to access the openssl connection object
- - - - -
2 changed files:
- nbxmpp/client.py
- nbxmpp/tls.py
Changes:
=====================================
nbxmpp/client.py
=====================================
@@ -119,6 +119,10 @@ class NonBlockingClient:
def get_bound_jid(self):
return self._registered_name
+ def get_ssl_connection(self):
+ if 'NonBlockingTCP' in self.__dict__:
+ return self.NonBlockingTCP.get_ssl_connection()
+
def disconnect(self, message=''):
"""
Called on disconnection - disconnect callback is picked based on state of
=====================================
nbxmpp/tls.py
=====================================
@@ -212,6 +212,7 @@ class NonBlockingTLS(PlugIn):
None is provided, a default list is used: HIGH:!aNULL
"""
PlugIn.__init__(self)
+ self._exported_methods = [self.get_ssl_connection]
self.cacerts = cacerts
self.mycerts = mycerts
if cipher_list is None:
@@ -423,3 +424,9 @@ class NonBlockingTLS(PlugIn):
return sslObj.get_finished()
except AttributeError:
raise NotImplementedError
+
+ def get_ssl_connection(self):
+ try:
+ return self._owner._sslObj
+ except Exception:
+ pass
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/40520af11ae80d17f12f74c0ab…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/40520af11ae80d17f12f74c0ab…
You're receiving this email because of your account on dev.gajim.org.