Philipp Hörist pushed to branch master at gajim / gajim
Commits:
30a20e16 by Philipp Hörist at 2018-11-11T09:21:46Z
Enforce min and max version for plugin manifest
This reduces problems with old plugins without max version
- - - - -
1 changed file:
- gajim/plugins/pluginmanager.py
Changes:
=====================================
gajim/plugins/pluginmanager.py
=====================================
@@ -650,6 +650,10 @@ class PluginManager(metaclass=Singleton):
min_v = conf.get('info', 'min_gajim_version', fallback=None)
max_v = conf.get('info', 'max_gajim_version', fallback=None)
+ if min_v is None or max_v is None:
+ log.warning('Plugin without min/max version: %s', elem_name)
+ continue
+
gajim_v = gajim.__version__.split('+', 1)[0]
gajim_v_cmp = parse_version(gajim_v)
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/30a20e16d25b285b5148cd1e5b518a545f…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/30a20e16d25b285b5148cd1e5b518a545f…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
8d95eb9b by Philipp Hörist at 2018-11-10T18:30:12Z
Better determine soundplayer on unix systems
- sys.platform == 'linux', excludes many other unix systems
- use shutil.which() to test if a command is available
- - - - -
1f31ab04 by Philipp Hörist at 2018-11-10T18:30:13Z
Remove unused code
Code is also not cross-platform compatible
- - - - -
0d703524 by Philipp Hörist at 2018-11-10T18:30:13Z
Dont test if winsound is available
Its a standard library which will be always available in our builds
- - - - -
5152611a by Philipp Hörist at 2018-11-10T18:30:18Z
Try to play sound on all unix systems
sys.platform == 'linux' excludeds other unix systems, for example FreeBSD
- - - - -
a7cc815c by Philipp Hörist at 2018-11-10T18:30:18Z
Move imports into function
- - - - -
02a9615b by Philipp Hörist at 2018-11-10T18:30:19Z
Dont test if precis_i18n is available
Its listed as dependency
- - - - -
e4a9ffe1 by Philipp Hörist at 2018-11-10T18:30:19Z
Dont test for sys.platform == 'linux'
This excludes other unix systems which was not intended
- - - - -
5 changed files:
- gajim/common/dbus_support.py
- gajim/common/helpers.py
- gajim/gui_interface.py
- gajim/notify.py
- gajim/roster_window.py
Changes:
=====================================
gajim/common/dbus_support.py
=====================================
@@ -36,7 +36,7 @@ try:
DBusGMainLoop(set_as_default=True)
except ImportError:
supported = False
- if sys.platform == 'linux': # windows and mac have no dbus
+ if sys.platform not in ('win32', 'darwin'):
print(_('D-Bus python bindings are missing in this computer'))
print(_('D-Bus capabilities of Gajim cannot be used'))
else:
@@ -47,7 +47,7 @@ else:
supported = True # does user have D-Bus bindings?
except dbus.DBusException:
supported = False
- if sys.platform == 'linux': # windows and mac have no dbus
+ if sys.platform not in ('win32', 'darwin'):
print(_('D-Bus does not run correctly on this machine'))
print(_('D-Bus capabilities of Gajim cannot be used'))
except exceptions.SystemBusNotPresent:
=====================================
gajim/common/helpers.py
=====================================
@@ -40,12 +40,15 @@ import socket
import time
import logging
import json
+import shutil
from datetime import datetime, timedelta
from distutils.version import LooseVersion as V
from encodings.punycode import punycode_encode
from string import Template
import nbxmpp
+from nbxmpp.stringprepare import nameprep
+import precis_i18n.codec # pylint: disable=unused-import
from gajim.common import caps_cache
from gajim.common import configpaths
@@ -54,35 +57,6 @@ from gajim.common.i18n import _
from gajim.common.i18n import ngettext
from gajim.common.caps_cache import muc_caps_cache
-try:
- import precis_i18n.codec # pylint: disable=unused-import
- HAS_PRECIS_I18N = True
-except ImportError:
- HAS_PRECIS_I18N = False
-
-HAS_SOUND = True
-if sys.platform == 'win32':
- try:
- import winsound # windows-only built-in module for playing wav
- except ImportError:
- HAS_SOUND = False
- print('Gajim is not able to playback sound because'
- 'pywin32 is missing', file=sys.stderr)
-
-elif sys.platform == 'darwin':
- try:
- from AppKit import NSSound
- except ImportError:
- HAS_SOUND = False
- print('Gajim is not able to playback sound because'
- 'pyobjc is missing', file=sys.stderr)
-
-try:
- import wave # posix-only fallback wav playback
- import ossaudiodev as oss
-except Exception:
- pass
-
log = logging.getLogger('gajim.c.helpers')
special_groups = (_('Transports'), _('Not in Roster'), _('Observers'), _('Groupchats'))
@@ -180,10 +154,7 @@ def parse_resource(resource):
"""
if resource:
try:
- if HAS_PRECIS_I18N:
- return resource.encode('Nickname').decode('utf-8')
- from nbxmpp.stringprepare import resourceprep
- return resourceprep.prepare(resource)
+ return resource.encode('Nickname').decode('utf-8')
except UnicodeError:
raise InvalidFormat('Invalid character in resource.')
@@ -217,7 +188,6 @@ def prep(user, server, resource):
if not server or len(server.encode('utf-8')) > 1023:
raise InvalidFormat(_('Server must be between 1 and 1023 bytes'))
try:
- from nbxmpp.stringprepare import nameprep
server = nameprep.prepare(server)
except UnicodeError:
raise InvalidFormat(_('Invalid character in hostname.'))
@@ -228,11 +198,7 @@ def prep(user, server, resource):
if not user or len(user.encode('utf-8')) > 1023:
raise InvalidFormat(_('Username must be between 1 and 1023 bytes'))
try:
- if HAS_PRECIS_I18N:
- user = user.encode('UsernameCaseMapped').decode('utf-8')
- else:
- from nbxmpp.stringprepare import nodeprep
- user = nodeprep.prepare(user)
+ user = user.encode('UsernameCaseMapped').decode('utf-8')
except UnicodeError:
raise InvalidFormat(_('Invalid character in username.'))
else:
@@ -242,11 +208,7 @@ def prep(user, server, resource):
if not resource or len(resource.encode('utf-8')) > 1023:
raise InvalidFormat(_('Resource must be between 1 and 1023 bytes'))
try:
- if HAS_PRECIS_I18N:
- resource = resource.encode('OpaqueString').decode('utf-8')
- else:
- from nbxmpp.stringprepare import resourceprep
- resource = resourceprep.prepare(resource)
+ resource = resource.encode('OpaqueString').decode('utf-8')
except UnicodeError:
raise InvalidFormat(_('Invalid character in resource.'))
else:
@@ -444,22 +406,26 @@ def get_uf_chatstate(chatstate):
return _('has closed the chat window or tab')
return ''
-def is_in_path(command, return_abs_path=False):
- """
- Return True if 'command' is found in one of the directories in the user's
- path. If 'return_abs_path' is True, return the absolute path of the first
- found command instead. Return False otherwise and on errors
- """
- for directory in os.getenv('PATH').split(os.pathsep):
- try:
- if command in os.listdir(directory):
- if return_abs_path:
- return os.path.join(directory, command)
- return True
- except OSError:
- # If the user has non directories in his path
- pass
- return False
+def find_soundplayer():
+ if sys.platform in ('win32', 'darwin'):
+ return
+
+ if app.config.get('soundplayer') != '':
+ return
+
+ commands = ('aucat', 'paplay', 'aplay', 'play', 'ossplay')
+ for command in commands:
+ if shutil.which(command) is not None:
+ if command == 'paplay':
+ command += ' -n gajim --property=media.role=event'
+ elif command in ('aplay', 'play'):
+ command += ' -q'
+ elif command == 'ossplay':
+ command += ' -qq'
+ elif command == 'aucat':
+ command += ' -i'
+ app.config.set('soundplayer', command)
+ break
def exec_command(command, use_shell=False, posix=True):
"""
@@ -758,38 +724,52 @@ def strip_soundfile_path(file_, dirs=None, abs_=True):
return file_
def play_sound_file(path_to_soundfile):
- if path_to_soundfile == 'beep':
- exec_command('beep')
- return
path_to_soundfile = check_soundfile_path(path_to_soundfile)
if path_to_soundfile is None:
return
- if sys.platform == 'win32' and HAS_SOUND:
+
+ if sys.platform == 'win32':
+ import winsound
try:
winsound.PlaySound(path_to_soundfile,
- winsound.SND_FILENAME|winsound.SND_ASYNC)
+ winsound.SND_FILENAME|winsound.SND_ASYNC)
except Exception:
log.exception('Sound Playback Error')
- elif sys.platform == 'linux':
- if app.config.get('soundplayer') == '':
- def _oss_play():
- sndfile = wave.open(path_to_soundfile, 'rb')
- nc, sw, fr, nf, _comptype, _compname = sndfile.getparams()
- dev = oss.open('/dev/dsp', 'w')
- dev.setparameters(sw * 8, nc, fr)
- dev.write(sndfile.readframes(nf))
- sndfile.close()
- dev.close()
- app.thread_interface(_oss_play)
+
+ elif sys.platform == 'darwin':
+ try:
+ from AppKit import NSSound
+ except ImportError:
+ log.exception('Sound Playback Error')
return
- player = app.config.get('soundplayer')
- command = build_command(player, path_to_soundfile)
- exec_command(command)
- elif sys.platform == 'darwin' and HAS_SOUND:
+
sound = NSSound.alloc()
sound.initWithContentsOfFile_byReference_(path_to_soundfile, True)
sound.play()
+ elif app.config.get('soundplayer') == '':
+ try:
+ import wave
+ import ossaudiodev
+ except Exception:
+ log.exception('Sound Playback Error')
+ return
+
+ def _oss_play():
+ sndfile = wave.open(path_to_soundfile, 'rb')
+ nc, sw, fr, nf, _comptype, _compname = sndfile.getparams()
+ dev = ossaudiodev.open('/dev/dsp', 'w')
+ dev.setparameters(sw * 8, nc, fr)
+ dev.write(sndfile.readframes(nf))
+ sndfile.close()
+ dev.close()
+ app.thread_interface(_oss_play)
+
+ else:
+ player = app.config.get('soundplayer')
+ command = build_command(player, path_to_soundfile)
+ exec_command(command)
+
def get_global_show():
maxi = 0
for account in app.connections:
=====================================
gajim/gui_interface.py
=====================================
@@ -1106,7 +1106,7 @@ class Interface:
if connected == invisible_show:
return
# send currently played music
- if (pep_supported and sys.platform == 'linux' and
+ if (pep_supported and sys.platform not in ('win32', 'darwin') and
app.config.get_per('accounts', account, 'publish_tune')):
self.enable_music_listener()
# enable location listener
@@ -2683,7 +2683,7 @@ class Interface:
self.remote_ctrl = None
# Handle screensaver
- if sys.platform == 'linux':
+ if sys.platform not in ('win32', 'darwin'):
logind.enable()
screensaver.enable()
@@ -2707,19 +2707,7 @@ class Interface:
# get transports type from DB
app.transport_type = app.logger.get_transports_type()
- if app.config.get('soundplayer') == '':
- # only on first time Gajim starts
- commands = ('paplay', 'aplay', 'play', 'ossplay')
- for command in commands:
- if helpers.is_in_path(command):
- if command == 'paplay':
- command += ' -n gajim --property=media.role=event'
- if command in ('aplay', 'play'):
- command += ' -q'
- elif command == 'ossplay':
- command += ' -qq'
- app.config.set('soundplayer', command)
- break
+ helpers.find_soundplayer()
self.last_ftwindow_update = 0
=====================================
gajim/notify.py
=====================================
@@ -82,7 +82,7 @@ class Notification:
self.daemon_capabilities = ['actions']
# Detect if actions are supported by the notification daemon
- if sys.platform == 'linux':
+ if sys.platform not in ('win32', 'darwin'):
def on_proxy_ready(source, res, data=None):
try:
proxy = Gio.DBusProxy.new_finish(res)
=====================================
gajim/roster_window.py
=====================================
@@ -4962,7 +4962,7 @@ class RosterWindow:
item = Gtk.CheckMenuItem(_('Publish Tune'))
pep_submenu.append(item)
- if sys.platform != 'linux':
+ if sys.platform in ('win32', 'darwin'):
item.set_sensitive(False)
else:
activ = app.config.get_per('accounts', account,
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/ac2a75db489d0812a1dbf0dffd4b3359b…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/ac2a75db489d0812a1dbf0dffd4b3359b…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
62cfd729 by Philipp Hörist at 2018-11-07T22:49:29Z
Remove unused import
- - - - -
1 changed file:
- gajim/gtk/tooltips.py
Changes:
=====================================
gajim/gtk/tooltips.py
=====================================
@@ -30,7 +30,6 @@ import logging
from datetime import datetime
from gi.repository import Gtk
-from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import Pango
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/62cfd7293a5bfe06e2d564acf2a4e192f4…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/62cfd7293a5bfe06e2d564acf2a4e192f4…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
fd97d642 by André Apitzsch at 2018-11-07T21:36:54Z
Test: Remove unused xmpp_mocks
- - - - -
2 changed files:
- test/integration/test_resolver.py
- − test/lib/xmpp_mocks.py
Changes:
=====================================
test/integration/test_resolver.py
=====================================
@@ -10,7 +10,6 @@ from gi.repository import GLib
from gajim.common import resolver
from gajim_mocks import *
-from xmpp_mocks import IdleQueueThread
NONSENSE_NAME = 'sfsdfsdfsdf.sdfs.fsd'
JABBERCZ_TXT_NAME = '_xmppconnect.jabber.cz'
=====================================
test/lib/xmpp_mocks.py deleted
=====================================
@@ -1,94 +0,0 @@
-'''
-Module with dummy classes for unit testing of XMPP and related code.
-'''
-
-import threading, time
-
-from mock import Mock
-
-from nbxmpp import idlequeue
-
-IDLEQUEUE_INTERVAL = 0.2 # polling interval. 200ms is used in Gajim as default
-IDLEMOCK_TIMEOUT = 30 # how long we wait for an event
-
-class IdleQueueThread(threading.Thread):
- '''
- Thread for regular processing of idlequeue.
- '''
- def __init__(self):
- self.iq = idlequeue.IdleQueue()
- self.stop = threading.Event() # Event to stop the thread main loop.
- self.stop.clear()
- threading.Thread.__init__(self)
-
- def run(self):
- while not self.stop.isSet():
- self.iq.process()
- time.sleep(IDLEQUEUE_INTERVAL)
-
- def stop_thread(self):
- self.stop.set()
-
-
-class IdleMock:
- '''
- Serves as template for testing objects that are normally controlled by GUI.
- Allows to wait for asynchronous callbacks with wait() method.
- '''
- def __init__(self):
- self._event = threading.Event()
- self._event.clear()
-
- def wait(self):
- '''
- Block until some callback sets the event and clearing the event
- subsequently.
- Returns True if event was set, False on timeout
- '''
- self._event.wait(IDLEMOCK_TIMEOUT)
- if self._event.isSet():
- self._event.clear()
- return True
- else:
- return False
-
- def set_event(self):
- self._event.set()
-
-class MockConnection(IdleMock, Mock):
- '''
- Class simulating Connection class from gajim/common/connection.py
-
- It is derived from Mock in order to avoid defining all methods
- from real Connection that are called from NBClient or Dispatcher
- ( _event_dispatcher for example)
- '''
-
- def __init__(self, *args):
- self.connect_succeeded = True
- IdleMock.__init__(self)
- Mock.__init__(self, *args)
-
- def on_connect(self, success, *args):
- '''
- Method called after connecting - after receiving <stream:features>
- from server (NOT after TLS stream restart) or connect failure
- '''
- self.connect_succeeded = success
- self.set_event()
-
-
- def on_auth(self, con, auth):
- '''
- Method called after authentication, regardless of the result.
-
- :Parameters:
- con : NonBlockingClient
- reference to authenticated object
- auth : string
- type of authetication in case of success ('old_auth', 'sasl') or
- None in case of auth failure
- '''
- self.auth_connection = con
- self.auth = auth
- self.set_event()
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/fd97d64205b2772c850b7e3cdc47def6b8…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/fd97d64205b2772c850b7e3cdc47def6b8…
You're receiving this email because of your account on dev.gajim.org.