Philipp Hörist pushed to branch master at gajim / gajim
Commits:
d06ba96a by Philipp Hörist at 2017-04-30T18:45:50+02:00
Update dependency in features window
gir1.2-gupnpigd-1.0 is the correct python3/GTK3 dependency on Debian
- - - - -
1 changed file:
- src/features_window.py
Changes:
=====================================
src/features_window.py
=====================================
--- a/src/features_window.py
+++ b/src/features_window.py
@@ -95,7 +95,7 @@ class FeaturesWindow:
_('Feature not available under Windows.')),
_('UPnP-IGD'): (self.gupnp_igd_available,
_('Ability to request your router to forward port for file transfer.'),
- _('Requires python-gupnp-igd.'),
+ _('Requires gir1.2-gupnpigd-1.0.'),
_('Feature not available under Windows.')),
_('UPower'): (self.upower_available,
_('Ability to disconnect properly just before suspending the machine.'),
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/d06ba96a89c18f93cd983f06280c50dc5f…
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
fe3a5a4a by Philipp Hörist at 2017-04-25T14:44:38+02:00
Make some methods public
- - - - -
1840ff23 by Philipp Hörist at 2017-04-25T14:51:35+02:00
Port Network Watcher to Gio API
- - - - -
89f1e982 by Philipp Hörist at 2017-04-29T23:37:55+02:00
Merge branch 'dbus' into 'master'
Port Network Watcher to Gio API
See merge request !88
- - - - -
7 changed files:
- src/common/config.py
- src/common/connection.py
- src/common/zeroconf/connection_zeroconf.py
- src/features_window.py
- src/gui_interface.py
- − src/network_manager_listener.py
- + src/network_watcher.py
Changes:
=====================================
src/common/config.py
=====================================
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -193,7 +193,6 @@ class Config:
'always_english_wikipedia': [opt_bool, False],
'always_english_wiktionary': [opt_bool, True],
'remote_control': [opt_bool, False, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True],
- 'networkmanager_support': [opt_bool, True, _('If True, listen to D-Bus signals from NetworkManager and change the status of accounts (provided they do not have listen_to_network_manager set to False and they sync with global status) based upon the status of the network connection.'), True],
'outgoing_chat_state_notifications': [opt_str, 'all', _('Sent chat state notifications. Can be one of all, composing_only, disabled.')],
'displayed_chat_state_notifications': [opt_str, 'all', _('Displayed chat state notifications in chat windows. Can be one of all, composing_only, disabled.')],
'autodetect_browser_mailer': [opt_bool, True, '', True],
@@ -387,7 +386,6 @@ class Config:
'msgwin-y-position': [opt_int, -1], # Default is to let the wm decide
'msgwin-width': [opt_int, 480],
'msgwin-height': [opt_int, 440],
- 'listen_to_network_manager': [opt_bool, True],
'is_zeroconf': [opt_bool, False],
'last_status': [opt_str, 'online'],
'last_status_msg': [opt_str, ''],
=====================================
src/common/connection.py
=====================================
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -198,7 +198,7 @@ class CommonConnection:
"""
gajim.ged.raise_event(event, self.name, data)
- def _reconnect(self):
+ def reconnect(self):
"""
To be implemented by derivated classes
"""
@@ -849,7 +849,7 @@ class Connection(CommonConnection, ConnectionHandlers):
def check_jid(self, jid):
return helpers.parse_jid(jid)
- def _reconnect(self):
+ def reconnect(self):
# Do not try to reco while we are already trying
self.time_to_reconnect = None
if self.connected < 2: # connection failed
@@ -894,7 +894,7 @@ class Connection(CommonConnection, ConnectionHandlers):
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
show=gajim.SHOW_LIST[self.connected]))
- def _disconnectedReconnCB(self):
+ def disconnectedReconnCB(self):
"""
Called when we are disconnected
"""
@@ -914,7 +914,7 @@ class Connection(CommonConnection, ConnectionHandlers):
show='error'))
if self.connection:
self.connection.UnregisterDisconnectHandler(
- self._disconnectedReconnCB)
+ self.disconnectedReconnCB)
self.disconnect()
if gajim.config.get_per('accounts', self.name, 'autoreconnect'):
self.connected = -1
@@ -925,7 +925,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self.status = gajim.status_before_autoaway[self.name]
gajim.status_before_autoaway[self.name] = ''
self.old_show = 'online'
- # this check has moved from _reconnect method
+ # this check has moved from reconnect method
# do exponential backoff until less than 5 minutes
if self.retrycount < 2 or self.last_time_to_reconnect is None:
self.last_time_to_reconnect = 5
@@ -1242,7 +1242,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self._connection_lost()
else:
# try reconnect if connection has failed before auth to server
- self._disconnectedReconnCB()
+ self.disconnectedReconnCB()
def connect_to_next_type(self, retry=False):
if self.redirected:
@@ -1409,7 +1409,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self.connected_hostname = self._current_host['host']
self.on_connect_failure = None
con.UnregisterDisconnectHandler(self._on_disconnected)
- con.RegisterDisconnectHandler(self._disconnectedReconnCB)
+ con.RegisterDisconnectHandler(self.disconnectedReconnCB)
log.debug('Connected to server %s:%s with %s' % (
self._current_host['host'], self._current_host['port'], con_type))
@@ -3038,7 +3038,7 @@ class Connection(CommonConnection, ConnectionHandlers):
if self.awaiting_xmpp_ping_id:
# We haven't got the pong in time, disco and reconnect
log.warning("No reply received for keepalive ping. Reconnecting.")
- self._disconnectedReconnCB()
+ self.disconnectedReconnCB()
def _reconnect_alarm(self):
if not gajim.config.get_per('accounts', self.name, 'active'):
@@ -3046,7 +3046,7 @@ class Connection(CommonConnection, ConnectionHandlers):
return
if self.time_to_reconnect:
if self.connected < 2:
- self._reconnect()
+ self.reconnect()
else:
self.time_to_reconnect = None
=====================================
src/common/zeroconf/connection_zeroconf.py
=====================================
--- a/src/common/zeroconf/connection_zeroconf.py
+++ b/src/common/zeroconf/connection_zeroconf.py
@@ -120,7 +120,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
def check_jid(self, jid):
return jid
- def _reconnect(self):
+ def reconnect(self):
# Do not try to reco while we are already trying
self.time_to_reconnect = None
gajim.log.debug('reconnect')
@@ -163,7 +163,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
gajim.nec.push_incoming_event(ZeroconfPresenceReceivedEvent(
None, conn=self, fjid=jid, show='offline', status=''))
- def _disconnectedReconnCB(self):
+ def disconnectedReconnCB(self):
"""
Called when we are disconnected. Comes from network manager for example
we don't try to reconnect, network manager will tell us when we can
=====================================
src/features_window.py
=====================================
--- a/src/features_window.py
+++ b/src/features_window.py
@@ -61,9 +61,9 @@ class FeaturesWindow:
_('Ability to encrypting chat messages with OpenPGP.'),
_('Requires gpg and python-gnupg (http://code.google.com/p/python-gnupg/).'),
_('Requires gpg.exe in PATH.')),
- _('Network-manager'): (self.network_manager_available,
+ _('Network-Watcher'): (self.network_watcher_available,
_('Autodetection of network status.'),
- _('Requires gnome-network-manager and python-dbus.'),
+ _('Requires gnome-network-manager'),
_('Feature not available under Windows.')),
_('Password encryption'): (self.some_keyring_available,
_('Passwords can be stored securely and not just in plaintext.'),
@@ -178,11 +178,9 @@ class FeaturesWindow:
def gpg_available(self):
return gajim.HAVE_GPG
- def network_manager_available(self):
- if os.name == 'nt':
- return False
- import network_manager_listener
- return network_manager_listener.supported
+ def network_watcher_available(self):
+ import network_watcher
+ return network_watcher.supported
def some_keyring_available(self):
if os.name == 'nt':
=====================================
src/gui_interface.py
=====================================
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -2973,9 +2973,7 @@ class Interface:
self.remote_ctrl = None
- if gajim.config.get('networkmanager_support') and \
- dbus_support.supported:
- import network_manager_listener
+ import network_watcher
if dbus_support.supported:
import upower_listener
=====================================
src/network_manager_listener.py deleted
=====================================
--- a/src/network_manager_listener.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# -*- coding: utf-8 -*-
-## src/network_manager_listener.py
-##
-## Copyright (C) 2006 Jeffrey C. Ollie <jeff AT ocjtech.us>
-## Nikos Kouremenos <kourem AT gmail.com>
-## Stefan Bethge <stefan AT lanpartei.de>
-## Copyright (C) 2006-2014 Yann Leboulanger <asterix AT lagaule.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 common import gajim
-
-
-def device_now_active(self, *args):
- """
- For Network Manager 0.6
- """
- for connection in gajim.connections.values():
- if gajim.config.get_per('accounts', connection.name,
- 'listen_to_network_manager') and connection.time_to_reconnect:
- connection._reconnect()
-
-def device_no_longer_active(self, *args):
- """
- For Network Manager 0.6
- """
- for connection in gajim.connections.values():
- if gajim.config.get_per('accounts', connection.name,
- 'listen_to_network_manager') and connection.connected > 1:
- connection._disconnectedReconnCB()
-
-def state_changed(state):
- """
- For Network Manager 0.7 - 0.9
- """
- if state == 70:
- for connection in gajim.connections.values():
- if gajim.config.get_per('accounts', connection.name,
- 'listen_to_network_manager') and connection.time_to_reconnect:
- connection._reconnect()
- else:
- for connection in gajim.connections.values():
- if gajim.config.get_per('accounts', connection.name,
- 'listen_to_network_manager') and connection.connected > 1:
- connection._disconnectedReconnCB()
-
-supported = False
-
-from common import dbus_support
-
-if dbus_support.supported:
- import dbus
-
- try:
- from common.dbus_support import system_bus
-
- bus = system_bus.bus()
-
- if 'org.freedesktop.NetworkManager' in bus.list_names():
- nm_object = bus.get_object('org.freedesktop.NetworkManager',
- '/org/freedesktop/NetworkManager')
- props = dbus.Interface(nm_object, "org.freedesktop.DBus.Properties")
- bus.add_signal_receiver(state_changed,
- 'StateChanged',
- 'org.freedesktop.NetworkManager',
- 'org.freedesktop.NetworkManager',
- '/org/freedesktop/NetworkManager')
- supported = True
-
- except dbus.DBusException:
- try:
- if 'org.freedesktop.NetworkManager' in bus.list_names():
- supported = True
-
- bus.add_signal_receiver(device_no_longer_active,
- 'DeviceNoLongerActive',
- 'org.freedesktop.NetworkManager',
- 'org.freedesktop.NetworkManager',
- '/org/freedesktop/NetworkManager')
-
- bus.add_signal_receiver(device_now_active,
- 'DeviceNowActive',
- 'org.freedesktop.NetworkManager',
- 'org.freedesktop.NetworkManager',
- '/org/freedesktop/NetworkManager')
- except Exception:
- pass
=====================================
src/network_watcher.py
=====================================
--- /dev/null
+++ b/src/network_watcher.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+## src/network_watcher.py
+##
+## Copyright (C) 2017 Philipp Hoerist <philipp AT hoerist.com>
+##
+## This file is part of Gajim.
+##
+## Gajim is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation; version 3 only.
+##
+## Gajim is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+##
+
+
+import logging
+
+from gi.repository import Gio, GLib
+
+from common import gajim
+
+log = logging.getLogger('gajim.network_watcher')
+
+
+supported = False
+
+
+def watch_name(name):
+ Gio.bus_watch_name(
+ Gio.BusType.SYSTEM,
+ name,
+ Gio.BusNameWatcherFlags.NONE,
+ appeared,
+ None)
+
+
+def signal_received(connection, sender_name, object_path,
+ interface_name, signal_name, parameters, *user_data):
+ connected = None
+ log.info('Signal received: %s - %s', interface_name, parameters)
+ if interface_name == 'org.freedesktop.NetworkManager':
+ # https://people.freedesktop.org/~lkundrak/nm-docs/nm-dbus-types.html
+ connected = parameters[0] == 70
+ if connected is not None:
+ GLib.timeout_add_seconds(
+ 2, update_connection_state,
+ connected)
+
+
+def appeared(connection, name, name_owner, *user_data):
+ global supported
+ supported = True
+ log.info('%s appeared', name)
+ if name == 'org.freedesktop.NetworkManager':
+ connection.signal_subscribe(
+ 'org.freedesktop.NetworkManager',
+ None,
+ 'StateChanged',
+ '/org/freedesktop/NetworkManager',
+ None,
+ Gio.DBusSignalFlags.NONE,
+ signal_received,
+ None)
+
+
+def update_connection_state(connected):
+ if connected:
+ for connection in gajim.connections.values():
+ log.info('Connect %s', connection.name)
+ connection.reconnect()
+ else:
+ for connection in gajim.connections.values():
+ if connection.connected > 1:
+ log.info('Disconnect %s', connection.name)
+ connection.disconnectedReconnCB()
+
+
+watch_name('org.freedesktop.NetworkManager')
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/d0357eaa2944ddfd2e4532a958a613c81…
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
caa63371 by Philipp Hörist at 2017-04-26T16:52:36+02:00
Dont deepcopy stanza for smack queue
the Node Object is not deepcopy-able in all cases.
Specifically the ESession negotiation does not work.
Sending the stanza first and adding the delay tag for the
queue afterwards makes it so we dont have to copy the object
- - - - -
c9ca5e48 by Philipp Hörist at 2017-04-26T17:11:17+02:00
Simplify code and satisfy pylint
- - - - -
9cfe6015 by Philipp Hörist at 2017-04-26T21:02:41+02:00
Merge branch 'master' into 'master'
Fix problems with deepcopy
See merge request !6
- - - - -
1 changed file:
- nbxmpp/dispatcher_nb.py
Changes:
=====================================
nbxmpp/dispatcher_nb.py
=====================================
--- a/nbxmpp/dispatcher_nb.py
+++ b/nbxmpp/dispatcher_nb.py
@@ -571,23 +571,23 @@ class XMPPDispatcher(PlugIn):
if self._owner._registered_name and not stanza.getAttr('from'):
stanza.setAttr('from', self._owner._registered_name)
+ self._owner.Connection.send(stanza, now)
+
# If no ID then it is a whitespace
if self.sm and self.sm.enabled and ID:
- stanza_copy = copy.deepcopy(stanza)
# add timestamp to message stanza in queue
- if stanza_copy.getName() == 'message' and \
- (stanza_copy.getType() == 'chat' or stanza_copy.getType() == 'groupchat'):
- our_jid = stanza_copy.getAttr('from')
- timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(None))
- stanza_copy.addChild('delay', namespace=NS_DELAY2,
- attrs={'from': our_jid or "Gajim", 'stamp': timestamp})
- self.sm.uqueue.append(stanza_copy)
+ if (stanza.getName() == 'message' and
+ stanza.getType() in ('chat', 'groupchat')):
+ our_jid = stanza.getAttr('from')
+ timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
+ stanza.addChild('delay', namespace=NS_DELAY2,
+ attrs={'from': our_jid or 'Gajim',
+ 'stamp': timestamp})
+ self.sm.uqueue.append(stanza)
self.sm.out_h += 1
- self._owner.Connection.send(stanza, now)
-
- if self.sm and self.sm.enabled and ID and len(self.sm.uqueue) > self.sm.max_queue:
- self.sm.request_ack()
+ if len(self.sm.uqueue) > self.sm.max_queue:
+ self.sm.request_ack()
return ID
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/compare/23a410277ac89e5cd69030c2f…
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
0f1d04e4 by Philipp Hörist at 2017-04-25T01:36:10+02:00
Fix path to logs.db in history manager
Logs.db is always at data_root, even if we set another config directory with -c
- - - - -
1 changed file:
- src/app_actions.py
Changes:
=====================================
src/app_actions.py
=====================================
--- a/src/app_actions.py
+++ b/src/app_actions.py
@@ -60,7 +60,7 @@ class AppActions():
gajim.interface.instances['accounts'] = config.AccountsWindow()
def on_history_manager(self, action, param):
- config_path = '-c %s' % gajim.gajimpaths.config_root
+ config_path = '-c %s' % gajim.gajimpaths.data_root
posix = os.name != 'nt'
if os.path.exists('history_manager.exe'): # Windows
helpers.exec_command('history_manager.exe %s' % config_path,
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/0f1d04e48808e8df20efbebcf2c49e41b2…
Philipp Hörist pushed to branch gajim_0.16 at gajim / gajim
Commits:
ffc762b6 by Philipp Hörist at 2017-04-25T01:30:47+02:00
Fix path to logs.db in history manager
Logs.db is always at data_root, even if we set another config directory with -c
- - - - -
1 changed file:
- src/roster_window.py
Changes:
=====================================
src/roster_window.py
=====================================
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -2856,7 +2856,7 @@ class RosterWindow:
gajim.connections[account].send_motd(server)
def on_history_manager_menuitem_activate(self, widget):
- config_path = '-c %s' % gajim.gajimpaths.config_root
+ config_path = '-c %s' % gajim.gajimpaths.data_root
posix = os.name != 'nt'
if os.path.exists('history_manager.exe'): # Windows
helpers.exec_command('history_manager.exe %s' % config_path,
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/ffc762b6578f87d8b08039e18dfb4f8423…