This file is indexed.

/usr/share/pyshared/quodlibet/qltk/remote.py is in exfalso 2.3.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# -*- coding: utf-8 -*-
# Copyright 2004-2005 Joe Wreschnig, Michael Urman, IƱigo Serna
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation

import os
import random
import re

import gobject
import gtk

from quodlibet import browsers
from quodlibet import config
from quodlibet import const
from quodlibet import util

from quodlibet.qltk.browser import LibraryBrowser
from quodlibet.qltk.properties import SongProperties
from quodlibet.util import copool

class FSInterface(object):
    """Provides a file in ~/.quodlibet to indicate what song is playing."""
    def __init__(self, player):
        player.connect('song-started', self.__started)
        player.connect('song-ended', self.__ended)
        gtk.quit_add(1, self.__cleanup)

    def __cleanup(self):
        try: os.unlink(const.CURRENT)
        except EnvironmentError: pass

    def __started(self, player, song):
        if song:
            try: f = file(const.CURRENT, "w")
            except EnvironmentError: pass
            else:
                f.write(song.to_dump())
                f.close()

    def __ended(self, player, song, stopped):
        try: os.unlink(const.CURRENT)
        except EnvironmentError: pass

class FIFOControl(object):
    """A FIFO to control the player/library from."""

    def __init__(self, library, window, player):
        self.__open(library, window, player)
        gtk.quit_add(1, self.__cleanup)

    def __cleanup(self):
        try: os.unlink(const.CONTROL)
        except EnvironmentError: pass

    def __open(self, *args):
        try:
            if not os.path.exists(const.CONTROL):
                util.mkdir(const.USERDIR)
                os.mkfifo(const.CONTROL, 0600)
            fifo = os.open(const.CONTROL, os.O_NONBLOCK)
            f = os.fdopen(fifo, "r", 4096)
            gobject.io_add_watch(
                f, gtk.gdk.INPUT_READ, self.__process, *args)
        except (EnvironmentError, AttributeError): pass

    def __getitem__(self, key):
        key = key.replace("-", "_")
        if key.startswith("_"): raise ValueError
        else:
            try: return getattr(self, "_"+key)
            except AttributeError: raise KeyError, key

    def __process(self, source, condition, *args):
        commands = source.read().rstrip("\n").splitlines()
        if commands == []:
            self.__open(*args)
            return False
        else:
            for command in commands:
                try:
                    try: cmd, arg = command.split(' ', 1)
                    except ValueError: self[command](*args)
                    else: self[cmd](arg, *args)
                except KeyError:
                    commands = args[1].browser.commands
                    try:
                        try: cmd, arg = command.split(' ', 1)
                        except ValueError: commands[command](*args)
                        else: commands[cmd](arg, *args)
                    except:
                        print_w(_("Invalid command %r received.") % command)
                except:
                    print_w(_("Invalid command %r received.") % command)
            return True

    def _previous(self, library, window, player): player.previous()
    def _next(self, library, window, player): player.next()
    def _pause(self, library, window, player): player.paused = True
    def _play(self, library, window, player):
        if player.song: player.paused = False
    def _play_pause(self, library, window, player):
        if player.song is None:
            player.reset()
        else: player.paused ^= True

    def _focus(self, library, window, player):
        window.show()
        window.present()

    def _volume(self, value, library, window, player):
        if value[0] in ('+', '-'):
            if len(value) > 1:
                try: change = (int(value[1:]) / 100.0)
                except ValueError: return
            else:
                change = 0.05
            if value[0] == '-': change = -change
            volume = player.volume + change
        else:
            try: volume = (int(value) / 100.0)
            except ValueError: return
        player.volume = min(1.0, max(0.0, volume))

    def _order(self, value, library, window, player):
        order = window.order
        try:
            order.set_active(
                ["inorder", "shuffle", "weighted", "onesong"].index(value))
        except ValueError:
            try: order.set_active(int(value))
            except (ValueError, TypeError):
                if value in ["t", "toggle"]:
                    order.set_active(not order.get_active())

    def _repeat(self, value, library, window, player):
        repeat = window.repeat
        if value in ["0", "off"]: repeat.set_active(False)
        elif value in ["1", "on"]: repeat.set_active(True)
        elif value in ["t", "toggle"]:
            repeat.set_active(not repeat.get_active())

    def _seek(self, time, library, window, player):
        seek_to = player.get_position()
        if time[0] == "+": seek_to += util.parse_time(time[1:]) * 1000
        elif time[0] == "-": seek_to -= util.parse_time(time[1:]) * 1000
        else: seek_to = util.parse_time(time) * 1000
        seek_to = min(player.song.get("~#length", 0) * 1000 -1,
                      max(0, seek_to))
        player.seek(seek_to)

    def _add_file(self, value, library, window, player):
        filename = os.path.realpath(value)
        song = library.add_filename(filename)
        if song:
            if song not in window.playlist.pl:
                queue = window.playlist.q
                queue.insert_before(queue.get_iter_first(), row=[song])
                player.next()
            else:
                player.go_to(library[filename])
                player.paused = False

    def _add_directory(self, value, library, window, player):
        filename = os.path.normpath(os.path.realpath(value))
        for added in library.scan([filename]): pass
        if window.browser.can_filter(None):
            window.browser.set_text(
                "filename = /^%s/c" % re.escape(filename))
            window.browser.activate()
        else:
            basepath = filename + "/"
            songs = [song for (filename, song) in library.iteritems()
                     if filename.startswith(basepath)]
            songs.sort(reverse=True)
            queue = window.playlist.q
            for song in songs:
                queue.insert_before(queue.get_iter_first(), row=[song])
        player.next()

    def _toggle_window(self, library, window, player):
        if window.get_property('visible'): window.hide()
        else: window.present()

    def _hide_window(self, library, window, player):
        window.hide()

    _show_window = _focus

    def _set_rating(self, value, library, window, player):
        song = player.song
        if song:
            try: song["~#rating"] = max(0.0, min(1.0, float(value)))
            except (ValueError, TypeError): pass
            else: library.changed([song])

    def _set_browser(self, value, library, window, player):
        Kind = browsers.get(value)
        if Kind is not browsers.search.EmptyBar:
            window.select_browser(None, value, library, player)
        else: print_w(_("Unknown browser %r.") % value)

    def _open_browser(self, value, library, window, player):
        Kind = browsers.get(value)
        if Kind is not browsers.search.EmptyBar:
            LibraryBrowser(Kind, library)
        else: print_w(_("Unknown browser %r.") % value)

    def _random(self, tag, library, window, player):
        if window.browser.can_filter(tag):
            values = window.browser.list(tag)
            if values:
                value = random.choice(values)
                window.browser.filter(tag, [value])

    def _filter(self, value, library, window, player):
        tag, values = value.split('=', 1)
        values = [v.decode("utf-8", "replace") for v in values.split("\x00")]
        if window.browser.can_filter(tag) and values:
            window.browser.filter(tag, values)

    def _unfilter(self, library, window, player):
        window.browser.unfilter()

    def _properties(self, value, library, window, player=None):
        if player is None:
            # no value given, use the current song; slide arguments
            # to the right.
            value, library, window, player = None, value, library, window
        if value:
            if value in library: songs = [library[value]]
            else: songs = library.query(value)
            SongProperties(songs, library, parent=self)
        else: SongProperties([player.song], library, parent=self)

    def _enqueue(self, value, library, window, player):
        playlist = window.playlist
        if value in library: songs = [library[value]]
        elif os.path.isfile(value):
            songs = [library.add_filename(os.path.realpath(value))]
        else: songs = library.query(value)
        songs.sort()
        playlist.enqueue(songs)

    def _unqueue(self, value, library, window, player):
        playlist = window.playlist
        if value in library: songs = [library[value]]
        else: songs = library.query(value)
        playlist.unqueue(songs)

    def _quit(self, library, window, player):
        window.destroy()

    def _status(self, value, library, window, player):
        try: f = file(value, "w")
        except EnvironmentError: pass
        else:
            if player.paused: strings = ["paused"]
            else: strings = ["playing"]
            strings.append(type(window.browser).__name__)
            strings.append("%0.3f" % window.volume.get_value())
            strings.append(window.order.get_active_name())
            strings.append((window.repeat.get_active() and "on") or "off")
            progress = 0
            if player.info:
                length = player.info.get("~#length", 0)
                if length: progress = player.get_position() / (length * 1000.0)
            strings.append("%0.3f" % progress)
            f.write(" ".join(strings) + "\n")
            try: f.write(window.browser.status + "\n")
            except AttributeError: pass
            f.close()

    def _song_list(self, value, library, window, player):
        if value.startswith("t"):
            value = not window.song_scroller.get_property('visible')
        else: value = value not in ['0', 'off', 'false']
        window.song_scroller.set_property('visible', value)

    def _queue(self, value, library, window, player):
        if value.startswith("t"):
            value = not window.qexpander.get_property('visible')
        else: value = value not in ['0', 'off', 'false']
        window.qexpander.set_property('visible', value)

    def _dump_playlist(self, value, library, window, player):
        try: f = file(value, "w")
        except EnvironmentError: pass
        else:
            for song in window.playlist.pl.get():
                f.write(song("~uri") + "\n")
            f.close()

    def _dump_queue(self, value, library, window, player):
        try: f = file(value, "w")
        except EnvironmentError: pass
        else:
            for song in window.playlist.q.get():
                f.write(song("~uri") + "\n")
            f.close()

    def _refresh(self, library, window, player):
        paths = util.split_scan_dirs(config.get("settings", "scan"))
        progress = window.statusbar.progress
        copool.add(library.rebuild, paths, progress, False, funcid="library")