Philipp Hörist pushed to branch gajim_0.16 at gajim / gajim
Commits:
b567bba5 by Philipp Hörist at 2017-05-26T23:55:06+02:00
Add config option to activate XEP-0146 commands
Some of the Commands have security implications, thats why we disable them per default
Fixes #8378
- - - - -
2 changed files:
- src/common/commands.py
- src/common/config.py
Changes:
=====================================
src/common/commands.py
=====================================
--- a/src/common/commands.py
+++ b/src/common/commands.py
@@ -345,9 +345,10 @@ class ConnectionCommands:
def __init__(self):
# a list of all commands exposed: node -> command class
self.__commands = {}
- for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand,
- LeaveGroupchatsCommand, FwdMsgThenDisconnectCommand):
- self.__commands[cmdobj.commandnode] = cmdobj
+ if gajim.config.get('remote_commands'):
+ for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand,
+ LeaveGroupchatsCommand, FwdMsgThenDisconnectCommand):
+ self.__commands[cmdobj.commandnode] = cmdobj
# a list of sessions; keys are tuples (jid, sessionid, node)
self.__sessions = {}
=====================================
src/common/config.py
=====================================
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -315,6 +315,7 @@ class Config:
'remember_opened_chat_controls': [ opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')],
'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')],
'pgp_encoding': [ opt_str, '', _('Sets the encoding used by python-gnupg'), True],
+ 'remote_commands': [opt_bool, False, _('If True, Gajim will execute XEP-0146 Commands.')],
}, {})
__options_per_key = {
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/b567bba56c814e8834e4fca3ee4acbb54a…
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
cb65cfc5 by Philipp Hörist at 2017-05-26T23:10:05+02:00
Add config option to activate XEP-0146 commands
Some of the Commands have security implications, thats why we disable them per default
Fixes #8378
- - - - -
2 changed files:
- src/common/commands.py
- src/common/config.py
Changes:
=====================================
src/common/commands.py
=====================================
--- a/src/common/commands.py
+++ b/src/common/commands.py
@@ -345,9 +345,10 @@ class ConnectionCommands:
def __init__(self):
# a list of all commands exposed: node -> command class
self.__commands = {}
- for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand,
- LeaveGroupchatsCommand, FwdMsgThenDisconnectCommand):
- self.__commands[cmdobj.commandnode] = cmdobj
+ if gajim.config.get('remote_commands'):
+ for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand,
+ LeaveGroupchatsCommand, FwdMsgThenDisconnectCommand):
+ self.__commands[cmdobj.commandnode] = cmdobj
# a list of sessions; keys are tuples (jid, sessionid, node)
self.__sessions = {}
=====================================
src/common/config.py
=====================================
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -315,6 +315,7 @@ class Config:
'show_avatar_in_tabs': [ opt_bool, False, _('Show a mini avatar in chat window tabs and in window icon')],
'use_keyring': [opt_bool, True, _('If True, Gajim will use the Systems Keyring to store account passwords.')],
'pgp_encoding': [ opt_str, '', _('Sets the encoding used by python-gnupg'), True],
+ 'remote_commands': [opt_bool, False, _('If True, Gajim will execute XEP-0146 Commands.')],
}, {})
__options_per_key = {
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/cb65cfc5aed9efe05208ebbb7fb2d41fcf…
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
9827c63f by Philipp Hörist at 2017-05-20T10:25:51+02:00
Clone correct project for windows build
- - - - -
1 changed file:
- appveyor.yml
Changes:
=====================================
appveyor.yml
=====================================
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -22,7 +22,7 @@ install:
}
bash 'pacman -Sy --noconfirm git'
- bash 'git clone https://dev.gajim.org/lovetox/gajim.git'
+ bash 'git clone https://dev.gajim.org/gajim/gajim.git'
- cmd: '%MSYS% C:/msys64/home/appveyor/gajim/win/build.sh'
# Ugly workaround, because i found no way to tell when mingw32.exe returns
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/9827c63f5f341f63dca521f19a70be825e…
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
148655c5 by Philipp Hörist at 2017-05-17T14:31:25+02:00
Terminate esession only if it was active before
This is a regression from !96
- - - - -
a73f0273 by Philipp Hörist at 2017-05-17T15:57:23+02:00
Remove frozen logging on windows
Because of the new build process this has become obsolete
we can now log on windows with a simple
´Gajim.exe > log.txt 2>&1´
- - - - -
33354823 by Philipp Hörist at 2017-05-18T21:42:40+02:00
Add 'encryption' config options group
We have to save the value per account and contact, because otherwise
it could lead to problems if a jid is added to more than one account.
As key this uses a string in the form of 'Account-BareJid'.
The config option group 'contacts' is not used because there are values
like 'speller_language' that make more sense to set on a Jid basis, rather than a
Account-Jid basis.
Treat an empty config value or no config value as 'disabled', instead
of writing a config value of 'disabled'. This has the benefit that we
dont have to write config values for contacts were we dont use encryption.
- - - - -
020e4e03 by Philipp Hörist at 2017-05-18T21:45:31+02:00
Name method more appropriate
- - - - -
6 changed files:
- src/chat_control.py
- src/chat_control_base.py
- src/common/config.py
- src/common/connection.py
- src/gajim.py
- src/groupchat_control.py
Changes:
=====================================
src/chat_control.py
=====================================
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -843,15 +843,15 @@ class ChatControl(ChatControlBase):
self.on_jingle_button_toggled(widget, 'video')
def set_lock_image(self):
- visible = self.encryption != 'disabled'
loggable = self.session and self.session.is_loggable()
- encryption_state = {'visible': visible,
+ encryption_state = {'visible': self.encryption is not None,
'enc_type': self.encryption,
'authenticated': False}
- gajim.plugin_manager.gui_extension_point(
- 'encryption_state' + self.encryption, self, encryption_state)
+ if self.encryption:
+ gajim.plugin_manager.gui_extension_point(
+ 'encryption_state' + self.encryption, self, encryption_state)
self._show_lock_image(**encryption_state)
@@ -875,8 +875,9 @@ class ChatControl(ChatControlBase):
self.lock_image.set_sensitive(visible)
def _on_authentication_button_clicked(self, widget):
- gajim.plugin_manager.gui_extension_point(
- 'encryption_dialog' + self.encryption, self)
+ if self.encryption:
+ gajim.plugin_manager.gui_extension_point(
+ 'encryption_dialog' + self.encryption, self)
def send_message(self, message, keyID='', chatstate=None, xhtml=None,
process_commands=True, attention=False):
@@ -1401,7 +1402,7 @@ class ChatControl(ChatControlBase):
def _on_message_tv_buffer_changed(self, textbuffer):
super()._on_message_tv_buffer_changed(textbuffer)
- if textbuffer.get_char_count():
+ if textbuffer.get_char_count() and self.encryption:
gajim.plugin_manager.gui_extension_point(
'typing' + self.encryption, self)
if (not self.session or not self.session.status) and \
@@ -1606,6 +1607,8 @@ class ChatControl(ChatControlBase):
self.begin_e2e_negotiation()
def terminate_esessions(self):
+ if not (self.session and self.session.enable_encryption):
+ return
# e2e was enabled, disable it
jid = str(self.session.jid)
thread_id = self.session.thread_id
=====================================
src/chat_control_base.py
=====================================
--- a/src/chat_control_base.py
+++ b/src/chat_control_base.py
@@ -396,8 +396,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
self._on_window_motion_notify)
self.handlers[id_] = parent_win.window
- self.encryption = 'disabled'
- self.set_encryption_state()
+ self.encryption = self.get_encryption_state()
if self.parent_win:
self.add_window_actions()
@@ -422,16 +421,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
action = Gio.SimpleAction.new_stateful(
"%s-encryptiongroup" % self.contact.jid,
GLib.VariantType.new("s"),
- GLib.Variant("s", self.encryption))
- action.connect("change-state", self.activate_encryption)
+ GLib.Variant("s", self.encryption or 'disabled'))
+ action.connect("change-state", self.change_encryption)
self.parent_win.window.add_action(action)
- def activate_encryption(self, action, param):
+ def change_encryption(self, action, param):
encryption = param.get_string()
+ if encryption == 'disabled':
+ encryption = None
+
if self.encryption == encryption:
return
- if encryption != 'disabled':
+ if encryption:
plugin = gajim.plugin_manager.encryption_plugins[encryption]
if not plugin.activate_encryption(self):
return
@@ -439,19 +441,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
if not self.widget_name == 'groupchat_control':
self.terminate_esessions()
action.set_state(param)
- gajim.config.set_per(
- 'contacts', self.contact.jid, 'encryption', encryption)
- self.encryption = encryption
+ self.set_encryption_state(encryption)
self.set_lock_image()
- def set_encryption_state(self):
- enc = gajim.config.get_per('contacts', self.contact.jid, 'encryption')
- if enc not in gajim.plugin_manager.encryption_plugins:
- self.encryption = 'disabled'
- gajim.config.set_per(
- 'contacts', self.contact.jid, 'encryption', 'disabled')
- else:
- self.encryption = enc
+ def set_encryption_state(self, encryption):
+ config_key = '%s-%s' % (self.account, self.contact.jid)
+ self.encryption = encryption
+ gajim.config.set_per('encryption', config_key,
+ 'encryption', self.encryption or '')
+
+ def get_encryption_state(self):
+ config_key = '%s-%s' % (self.account, self.contact.jid)
+ state = gajim.config.get_per('encryption', config_key, 'encryption')
+ return state or None
def set_speller(self):
# now set the one the user selected
=====================================
src/common/config.py
=====================================
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -480,9 +480,10 @@ class Config:
'state_muc_directed_msg_color': [ opt_color, 'red2' ],
}, {}),
'contacts': ({
- 'encryption': [ opt_str, '', _('Encryption used for this contact.')],
'speller_language': [ opt_str, '', _('Language for which we want to check misspelled words')],
}, {}),
+ 'encryption': ({'encryption': [ opt_str, '', _('The currently active encryption for that contact')],
+ },{}),
'rooms': ({
'speller_language': [ opt_str, '', _('Language for which we want to check misspelled words')],
'muc_restore_lines': [opt_int, -2, _('How many lines to request from server when entering a groupchat. -1 means no limit, -2 means global value')],
=====================================
src/common/connection.py
=====================================
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -2053,8 +2053,10 @@ class Connection(CommonConnection, ConnectionHandlers):
def _nec_stanza_message_outgoing(self, obj):
if obj.conn.name != self.name:
return
- encryption = gajim.config.get_per('contacts', obj.jid, 'encryption')
- if encryption != 'disabled':
+
+ config_key = '%s-%s' % (self.name, obj.jid)
+ encryption = gajim.config.get_per('encryption', config_key, 'encryption')
+ if encryption:
gajim.plugin_manager.gui_extension_point(
'encrypt' + encryption, self, obj, self.send_message)
else:
@@ -2672,8 +2674,10 @@ class Connection(CommonConnection, ConnectionHandlers):
def _nec_gc_stanza_message_outgoing(self, obj):
if obj.conn.name != self.name:
return
- encryption = gajim.config.get_per('contacts', obj.jid, 'encryption')
- if encryption != 'disabled':
+
+ config_key = '%s-%s' % (self.name, obj.jid)
+ encryption = gajim.config.get_per('encryption', config_key, 'encryption')
+ if encryption:
gajim.plugin_manager.gui_extension_point(
'gc_encrypt' + encryption, self, obj, self.send_gc_message)
else:
=====================================
src/gajim.py
=====================================
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -130,9 +130,6 @@ class GajimApplication(Gtk.Application):
configpaths.gajimpaths.init(
self.config_path, self.profile, self.profile_separation)
- if hasattr(sys, 'frozen'):
- self.frozen_logging(configpaths.gajimpaths.config_root)
-
from common import gajim
from common import check_paths
from common import exceptions
@@ -311,38 +308,6 @@ class GajimApplication(Gtk.Application):
warnings.showwarning = warn_with_traceback
warnings.filterwarnings(action="always")
- def frozen_logging(self, path):
- import warnings
- if not os.path.exists(path):
- os.mkdir(path, 0o700)
-
- class MyStd(object):
- _file = None
- _error = None
- log_file = os.path.join(path, 'gajim.log')
-
- def write(self, text):
- if self._file is None and self._error is None:
- try:
- self._file = open(self.log_file, 'a')
- except Exception as details:
- self._error = details
- if self._file is not None:
- self._file.write(text)
- self._file.flush()
-
- def flush(self):
- if self._file is not None:
- self._file.flush()
-
- def isatty(self):
- return False
-
- outerr = MyStd()
- sys.stdout = outerr
- sys.stderr = outerr
- warnings.filterwarnings(action='ignore')
-
def add_actions(self):
''' Build Application Actions '''
from app_actions import AppActions
=====================================
src/groupchat_control.py
=====================================
--- a/src/groupchat_control.py
+++ b/src/groupchat_control.py
@@ -770,14 +770,13 @@ class GroupchatControl(ChatControlBase):
self.draw_contact(nick)
def set_lock_image(self):
- visible = self.encryption != 'disabled'
-
- encryption_state = {'visible': visible,
+ encryption_state = {'visible': self.encryption is not None,
'enc_type': self.encryption,
'authenticated': False}
- gajim.plugin_manager.gui_extension_point(
- 'encryption_state' + self.encryption, self, encryption_state)
+ if self.encryption:
+ gajim.plugin_manager.gui_extension_point(
+ 'encryption_state' + self.encryption, self, encryption_state)
self._show_lock_image(**encryption_state)
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/381b9b0a6c1daae6c8cc04ab25fecc10e…