This file is indexed.

/usr/lib/python2.7/dist-packages/deejayd/interfaces.py is in deejayd-client 0.10.0-5.

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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# Deejayd, a media player daemon
# Copyright (C) 2007-2009 Mickael Royer <mickael.royer@gmail.com>
#                         Alexandre Rossi <alexandre.rossi@gmail.com>
#
# This program 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; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


import locale


class DeejaydError(Exception):
    """General purpose error structure."""

    # Handle unicode messages, what Exceptions cannot. See Python issue at
    # http://bugs.python.org/issue2517
    def __str__(self):
        if type(self.message) is unicode:
            return str(self.message.encode(locale.getpreferredencoding()))
        else:
            return str(self.message)

    def __unicode__(self):
        if type(self.message) is unicode:
            return self.message
        else:
            return unicode(self.message)

class DeejaydAnswer(object):
    """General purpose core answer container."""

    def __init__(self):
        self.contents = None
        self.error = False

    def set_error(self, msg):
        self.contents = msg
        self.error = True

    def get_contents(self):
        if self.error:
            raise DeejaydError(self.contents)
        return self.contents


class DeejaydKeyValue(DeejaydAnswer):
    """Dictionnary answer."""

    def __getitem__(self, name):
        self.get_contents()
        return self.contents[name]

    def keys(self):
        self.get_contents()
        return self.contents.keys()

    def items(self):
        self.get_contents()
        return self.contents.items()


class DeejaydList(DeejaydAnswer):
    """List answer."""

    def __len__(self):
        self.get_contents()
        return len(self.contents)

    def __iter__(self):
        self.get_contents()
        return self.contents.__iter__()


class DeejaydFileList(DeejaydAnswer):
    """File list answer."""

    def __init__(self):
        DeejaydAnswer.__init__(self)
        self.root_dir = ""
        self.files = []
        self.directories = []

    def set_rootdir(self, dir):
        self.root_dir = dir

    def add_file(self, file):
        self.files.append(file)

    def add_dir(self, dir):
        self.directories.append(dir)

    def set_files(self, files):
        self.files = files

    def set_directories(self, dirs):
        self.directories = dirs

    def get_files(self):
        self.get_contents()
        return self.files

    def get_directories(self):
        self.get_contents()
        return self.directories


class DeejaydMediaList(DeejaydAnswer):
    """Media list answer."""

    def __init__(self):
        DeejaydAnswer.__init__(self)
        self.medias = []
        self.filter = None
        self.sort = None
        self.media_type = None

    def add_media(self, media):
        self.medias.append(media)

    def get_medias(self):
        self.get_contents()
        return self.medias

    def set_medias(self, medias):
        self.medias = medias

    def is_magic(self):
        self.get_contents()
        return self.filter != None

    def set_media_type(self, media_type):
        self.media_type = media_type

    def get_media_type(self):
        self.get_contents()
        return self.media_type

    def set_filter(self, filter):
        self.filter = filter

    def get_filter(self):
        self.get_contents()
        return self.filter

    def set_sort(self, sort):
        self.sort = sort

    def get_sort(self):
        self.get_contents()
        return self.sort


class DeejaydDvdInfo(DeejaydAnswer):
    """Dvd information answer."""

    def __init__(self):
        DeejaydAnswer.__init__(self)
        self.dvd_content = {}

    def set_dvd_content(self, infos):
        self.dvd_content.update(infos)

    def add_track(self, track):
        if "track" not in self.dvd_content.keys():
            self.dvd_content['track'] = []
        self.dvd_content['track'].append(track)

    def set_tracks(self, tracks):
        self.dvd_content['track'] = tracks

    def get_dvd_contents(self):
        self.get_contents()
        if "track" not in self.dvd_content.keys():
            self.dvd_content['track'] = []
        return self.dvd_content


class DeejaydStaticPlaylist(object):
    """ Static playlist object """
    type = "static"

    def get(self, first=0, length=-1):
        raise NotImplementedError

    def add_path(self, path):
        return self.add_paths([path])

    def add_paths(self, paths):
        raise NotImplementedError

    def add_song(self, song_id):
        return self.add_songs([song_id])

    def add_songs(self, song_ids):
        raise NotImplementedError


class DeejaydMagicPlaylist(object):
    """ Magic playlist object """
    type = "magic"

    def get(self, first=0, length=-1):
        raise NotImplementedError

    def add_filter(self, filter):
        raise NotImplementedError

    def remove_filter(self, filter):
        raise NotImplementedError

    def clear_filters(self):
        raise NotImplementedError

    def get_properties(self):
        raise NotImplementedError

    def set_property(self, key, value):
        raise NotImplementedError


class DeejaydWebradioList(object):
    """Webradio list management."""

    def get(self, first = 0, length = None):
        raise NotImplementedError

    def get_available_sources(self):
        raise NotImplementedError

    def get_source_categories(self, source_name):
        raise NotImplementedError

    def set_source(self, source_name):
        raise NotImplementedError

    def set_source_categorie(self, categorie):
        raise NotImplementedError

    def add_webradio(self, name, urls):
        raise NotImplementedError

    def delete_webradio(self, wr_id):
        return self.delete_webradios([wr_id])

    def delete_webradios(self, wr_ids):
        raise NotImplementedError

    def clear(self):
        raise NotImplementedError


class DeejaydQueue(object):
    """Queue management."""

    def get(self, first = 0, length = None):
        raise NotImplementedError

    def add_path(self, path, pos = None):
        return self.add_paths([path], pos)

    def add_paths(self, paths, pos = None):
        raise NotImplementedError

    def add_song(self, song_id, pos = None):
        return self.add_songs([song_id], pos)

    def add_songs(self, song_ids, pos = None):
        raise NotImplementedError

    def load_playlist(self, pl_id, pos = None):
        return self.load_playlists([pl_id], pos)

    def load_playlists(self, pl_ids, pos = None):
        raise NotImplementedError

    def move(self, ids, new_pos):
        raise NotImplementedError

    def clear(self):
        raise NotImplementedError

    def del_song(self, id):
        return self.del_songs([id])

    def del_songs(self, ids):
        raise NotImplementedError


class DeejaydPanel(object):

    def get(self, first = 0, length = None):
        raise NotImplementedError

    def get_active_list(self):
        raise NotImplementedError

    def get_panel_tags(self):
        raise NotImplementedError

    def set_active_list(self, type, pl_id=""):
        raise NotImplementedError

    def set_panel_filters(self, tag, values):
        raise NotImplementedError

    def remove_panel_filters(self, tag):
        raise NotImplementedError

    def clear_panel_filters(self):
        raise NotImplementedError

    def set_search_filter(self, tag, value):
        raise NotImplementedError

    def clear_search_filter(self):
        raise NotImplementedError

    def set_sorts(self, sort):
        raise NotImplementedError


class DeejaydPlaylistMode(object):

    def get(self, first = 0, length = None):
        raise NotImplementedError

    def save(self, name):
        raise NotImplementedError

    def add_path(self, path, pos = None):
        return self.add_paths([path], pos)

    def add_paths(self, paths, pos = None):
        raise NotImplementedError

    def add_song(self, song_id, pos = None):
        return self.add_songs([song_id], pos)

    def add_songs(self, song_ids, pos = None):
        raise NotImplementedError

    def load(self, pl_id, pos = None):
        return self.loads([pl_id], pos)

    def loads(self, pl_ids, pos = None):
        raise NotImplementedError

    def move(self, ids, new_pos):
        raise NotImplementedError

    def shuffle(self):
        raise NotImplementedError

    def clear(self):
        raise NotImplementedError

    def del_song(self, id):
        return self.del_songs([id])

    def del_songs(self, ids):
        raise NotImplementedError


class DeejaydVideo(object):
    """Video management."""

    def get(self, first = 0, length = None):
        raise NotImplementedError

    def set(self, value, type = "directory"):
        raise NotImplementedError

    def set_sorts(self, sorts):
        raise NotImplementedError


class DeejaydSignal(object):

    SIGNALS = ('player.status',       # Player status change (play/pause/stop/
                                      # random/repeat/volume/manseek)
               'player.current',      # Currently played song change
               'player.plupdate',     # The current playlist has changed
               'playlist.listupdate', # The stored playlist list has changed
                                      # (either a saved playlist has been saved
                                      # or deleted).
               'playlist.update',     # A recorded playlist (static or magic)
                                      # has changed
                                      # set id of playlist as attribute
               'webradio.listupdate',
               'panel.update',
               'queue.update',
               'video.update',
               'dvd.update',
               'mode',                # Mode change
               'mediadb.aupdate',     # Media library audio update
               'mediadb.vupdate',     # Media library video update
               'mediadb.mupdate',     # a media has been updated
                                      # set id and type of media as attribute
                                      # set type of update as attribute
              )

    def __init__(self, name=None, attrs = {}):
        self.name = name
        self.attrs = attrs

    def set_name(self, name):
        self.name = name

    def get_name(self):
        return self.name

    def get_attrs(self):
        return self.attrs

    def get_attr(self, key):
        return self.attrs[key]

    def set_attr(self, key, value):
        self.attrs[key] = value


class DeejaydCore(object):
    """Abstract class for a deejayd core."""

    def __init__(self):
        self._clear_subscriptions()

    def ping(self):
        raise NotImplementedError

    def play_toggle(self):
        raise NotImplementedError

    def stop(self):
        raise NotImplementedError

    def previous(self):
        raise NotImplementedError

    def next(self):
        raise NotImplementedError

    def seek(self, pos, relative = False):
        raise NotImplementedError

    def get_current(self):
        raise NotImplementedError

    def go_to(self, id, id_type = None, source = None):
        raise NotImplementedError

    def set_volume(self, volume_value):
        raise NotImplementedError

    def set_option(self, source, option_name, option_value):
        raise NotImplementedError

    def set_mode(self, mode_name):
        raise NotImplementedError

    def get_mode(self):
        raise NotImplementedError

    def set_player_option(self, option_name, option_value):
        raise NotImplementedError

    def get_status(self):
        raise NotImplementedError

    def get_stats(self):
        raise NotImplementedError

    def update_audio_library(self, force = False, sync = False):
        raise NotImplementedError

    def update_video_library(self, force = False, sync = False):
        raise NotImplementedError

    def create_recorded_playlist(self, name, type):
        raise NotImplementedError

    def get_recorded_playlist(self, pl_id):
        raise NotImplementedError

    def erase_playlist(self, pl_ids):
        raise NotImplementedError

    def get_playlist_list(self):
        raise NotImplementedError

    def get_playlist(self):
        raise NotImplementedError

    def get_webradios(self):
        raise NotImplementedError

    def get_queue(self):
        raise NotImplementedError

    def get_panel(self):
        raise NotImplementedError

    def get_video(self):
        raise NotImplementedError

    def set_media_rating(self, media_ids, rating, type = "audio"):
        raise NotImplementedError

    def get_audio_dir(self, dir=None):
        raise NotImplementedError

    def get_audio_cover(self, media_id):
        raise NotImplementedError

    def audio_search(self, search_txt, type = 'all'):
        raise NotImplementedError

    def get_video_dir(self, dir=None):
        raise NotImplementedError

    def dvd_reload(self):
        raise NotImplementedError

    def mediadb_list(self, taglist, filter):
        raise NotImplementedError

    def get_dvd_content(self):
        raise NotImplementedError

    def __get_next_sub_id(self):
        sub_id = self.__sub_id_counter
        self.__sub_id_counter = self.__sub_id_counter + 1
        return sub_id

    def subscribe(self, signal_name, callback):
        """Subscribe to a signal with a callback. Returns an id."""
        if signal_name not in DeejaydSignal.SIGNALS:
            return DeejaydError('Unknown signal provided for subscription.')

        sub_id = self.__get_next_sub_id()
        self.__sig_subscriptions[sub_id] = (signal_name, callback)
        return sub_id

    def unsubscribe(self, sub_id):
        """Unsubscribe using the provied id."""
        try:
            del self.__sig_subscriptions[sub_id]
        except IndexError:
            raise DeejaydError('Unknown subscription id')

    def get_subscriptions(self):
        """Get the list of currently subcribed signals for this instance."""
        return dict([(sub_id, sub[0]) for (sub_id, sub)\
                                      in self.__sig_subscriptions.items()])

    def _clear_subscriptions(self):
        self.__sig_subscriptions = {}
        self.__sub_id_counter = 0

    def _dispatch_signal(self, signal):
        for cb in [sub[1] for sub in self.__sig_subscriptions.values()\
                                  if sub[0] == signal.get_name()]:
            cb(signal)

    def _dispatch_signame(self, signal_name, attrs = {}):
        self._dispatch_signal(DeejaydSignal(signal_name, attrs))


# vim: ts=4 sw=4 expandtab