Philipp Hörist pushed to branch master at gajim / gajim

Commits:

6 changed files:

Changes:

  • README.md
    ... ... @@ -25,6 +25,7 @@
    25 25
     - gir1.2-gupnpigd-1.0 for better NAT traversing
    
    26 26
     - gir1.2-networkmanager-1.0 for network lose detection
    
    27 27
     - gir1.2-geoclue-2.0 for sharing your location
    
    28
    +- gir1.2-gsound-1.0 for sound on Linux
    
    28 29
     
    
    29 30
     ### Compile-time Requirements
    
    30 31
     
    

  • flatpak/org.gajim.Gajim.yaml
    ... ... @@ -166,6 +166,13 @@ modules:
    166 166
             url: https://files.pythonhosted.org/packages/b6/ec/9abe8377d9819fc0383992aaa1b8ce263b45a2371f9f30204abf61029937/precis_i18n-1.0.1-py3-none-any.whl
    
    167 167
             sha256: dc9f9fb0c080af9454adce9cc1ddcd718309f3a99ca05186f65e9f6b0654dcd9
    
    168 168
     
    
    169
    +  - name: gsound
    
    170
    +    sources:
    
    171
    +      - type: git
    
    172
    +        url: https://gitlab.gnome.org/GNOME/gsound.git
    
    173
    +        tag: 1.0.2
    
    174
    +        commit: a86946b494aa32782b3f6334344d07b5c11d5219
    
    175
    +
    
    169 176
       - name: gspell
    
    170 177
         cleanup:
    
    171 178
           - /bin
    

  • gajim/common/app.py
    ... ... @@ -144,6 +144,8 @@ socks5queue = None
    144 144
     
    
    145 145
     gupnp_igd = None
    
    146 146
     
    
    147
    +gsound_ctx = None
    
    148
    +
    
    147 149
     gajim_identity = DiscoIdentity(category='client',
    
    148 150
                                    type='pc',
    
    149 151
                                    name='Gajim')
    
    ... ... @@ -197,6 +199,7 @@ _dependencies = {
    197 199
         'GEOCLUE': False,
    
    198 200
         'UPNP': False,
    
    199 201
         'PYCURL': False,
    
    202
    +    'GSOUND': False,
    
    200 203
         'GSPELL': False,
    
    201 204
         'IDLE': False,
    
    202 205
     }
    
    ... ... @@ -298,6 +301,21 @@ def detect_dependencies():
    298 301
         except Exception:
    
    299 302
             pass
    
    300 303
     
    
    304
    +    # GSOUND
    
    305
    +    try:
    
    306
    +        gi.require_version('GSound', '1.0')
    
    307
    +        from gi.repository import GLib
    
    308
    +        from gi.repository import GSound
    
    309
    +        global gsound_ctx
    
    310
    +        gsound_ctx = GSound.Context()
    
    311
    +        try:
    
    312
    +            gsound_ctx.init()
    
    313
    +            _dependencies['GSOUND'] = True
    
    314
    +        except GLib.Error as error:
    
    315
    +            log('gajim').error(error)
    
    316
    +    except (ImportError, ValueError):
    
    317
    +        pass
    
    318
    +
    
    301 319
         # GSPELL
    
    302 320
         try:
    
    303 321
             gi.require_version('Gspell', '1')
    

  • gajim/common/config.py
    ... ... @@ -115,8 +115,6 @@ class Config:
    115 115
             'show_ascii_formatting_chars': [opt_bool, True, _('If enabled, do not '
    
    116 116
                     'remove */_ . So *abc* will be bold but with * * not removed.')],
    
    117 117
             'sounds_on': [opt_bool, True],
    
    118
    -        # 'aplay', 'play', 'esdplay', 'artsplay' detected first time only
    
    119
    -        'soundplayer': [opt_str, ''],
    
    120 118
             'gc_refer_to_nick_char': [opt_str, ',', _('Character to add after nickname when using nickname completion (tab) in group chat.')],
    
    121 119
             'gc_proposed_nick_char': [opt_str, '_', _('Character to propose to add after desired nickname when nickname is already used in group chat.')],
    
    122 120
             'msgwin-max-state': [opt_bool, False],
    

  • gajim/common/helpers.py
    ... ... @@ -42,7 +42,6 @@ import socket
    42 42
     import time
    
    43 43
     import logging
    
    44 44
     import json
    
    45
    -import shutil
    
    46 45
     import copy
    
    47 46
     import collections
    
    48 47
     from collections import defaultdict
    
    ... ... @@ -453,27 +452,6 @@ def get_uf_chatstate(chatstate):
    453 452
             return _('has closed the chat window or tab')
    
    454 453
         return ''
    
    455 454
     
    
    456
    -def find_soundplayer():
    
    457
    -    if sys.platform in ('win32', 'darwin'):
    
    458
    -        return
    
    459
    -
    
    460
    -    if app.config.get('soundplayer') != '':
    
    461
    -        return
    
    462
    -
    
    463
    -    commands = ('aucat', 'paplay', 'aplay', 'play', 'ossplay')
    
    464
    -    for command in commands:
    
    465
    -        if shutil.which(command) is not None:
    
    466
    -            if command == 'paplay':
    
    467
    -                command += ' -n gajim --property=media.role=event'
    
    468
    -            elif command in ('aplay', 'play'):
    
    469
    -                command += ' -q'
    
    470
    -            elif command == 'ossplay':
    
    471
    -                command += ' -qq'
    
    472
    -            elif command == 'aucat':
    
    473
    -                command += ' -i'
    
    474
    -            app.config.set('soundplayer', command)
    
    475
    -            break
    
    476
    -
    
    477 455
     def exec_command(command, use_shell=False, posix=True):
    
    478 456
         """
    
    479 457
         execute a command. if use_shell is True, we run the command as is it was
    
    ... ... @@ -702,28 +680,11 @@ def play_sound_file(path_to_soundfile):
    702 680
             sound.initWithContentsOfFile_byReference_(path_to_soundfile, True)
    
    703 681
             sound.play()
    
    704 682
     
    
    705
    -    elif app.config.get('soundplayer') == '':
    
    683
    +    elif app.is_installed('GSOUND'):
    
    706 684
             try:
    
    707
    -            import wave
    
    708
    -            import ossaudiodev
    
    709
    -        except Exception:
    
    710
    -            log.exception('Sound Playback Error')
    
    711
    -            return
    
    712
    -
    
    713
    -        def _oss_play():
    
    714
    -            sndfile = wave.open(path_to_soundfile, 'rb')
    
    715
    -            nc, sw, fr, nf, _comptype, _compname = sndfile.getparams()
    
    716
    -            dev = ossaudiodev.open('/dev/dsp', 'w')
    
    717
    -            dev.setparameters(sw * 8, nc, fr)
    
    718
    -            dev.write(sndfile.readframes(nf))
    
    719
    -            sndfile.close()
    
    720
    -            dev.close()
    
    721
    -        app.thread_interface(_oss_play)
    
    722
    -
    
    723
    -    else:
    
    724
    -        player = app.config.get('soundplayer')
    
    725
    -        command = build_command(player, path_to_soundfile)
    
    726
    -        exec_command(command)
    
    685
    +            app.gsound_ctx.play_simple({'media.filename' : path_to_soundfile})
    
    686
    +        except GLib.Error as error:
    
    687
    +            log.error('Could not play sound: %s', error.message)
    
    727 688
     
    
    728 689
     def get_global_show():
    
    729 690
         maxi = 0
    

  • gajim/gui_interface.py
    ... ... @@ -2221,8 +2221,6 @@ class Interface:
    2221 2221
             # get transports type from DB
    
    2222 2222
             app.transport_type = app.logger.get_transports_type()
    
    2223 2223
     
    
    2224
    -        helpers.find_soundplayer()
    
    2225
    -
    
    2226 2224
             self.last_ftwindow_update = 0
    
    2227 2225
     
    
    2228 2226
             self.music_track_changed_signal = None