Mercurial > libervia-backend
diff src/plugins/plugin_misc_radiocol.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | 593331663b80 |
children | beaf6bec2fcd |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_radiocol.py Fri Jan 18 17:55:27 2013 +0100 +++ b/src/plugins/plugin_misc_radiocol.py Fri Jan 18 17:55:34 2013 +0100 @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """ -SAT plugin for managing Radiocol +SAT plugin for managing Radiocol Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) This program is free software: you can redistribute it and/or modify @@ -80,7 +80,7 @@ elt["type"] = type elt.addElement((NC_RADIOCOL, RADIOC_TAG)) return elt - + def __create_started_elt(self): """Create a game_started domish element""" started_elt = domish.Element((None,'started')) @@ -122,14 +122,14 @@ self.radiocolCreate(_room_jid.userhost(), profile_key=profile) for occupant in occupants: self.host.plugins["XEP-0249"].invite(jid.JID(occupant), room.occupantJID.userhostJID(), {"game":"Radiocol"}, profile) - + def after_init(ignore): room_name = "sat_radiocol_%s" % self.host.plugins["XEP-0045"].getUniqueName(profile_key) print "\n\n===> room_name:", room_name muc_service = None for service in self.host.memory.getServerServiceEntities("conference", "text", profile): if not ".irc." in service.userhost(): - #FIXME: + #FIXME: #This awfull ugly hack is here to avoid an issue with openfire: the irc gateway #use "conference/text" identity (instead of "conference/irc"), there is certainly a better way #to manage this, but this hack fill do it for test purpose @@ -138,7 +138,7 @@ if not muc_service: error(_("Can't find a MUC service")) return - + _jid, xmlstream = self.host.getJidNStream(profile) d = self.host.plugins["XEP-0045"].join(jid.JID("%s@%s" % (room_name, muc_service.userhost())), _jid.user, {}, profile) d.addCallback(radiocolRoomJoined) @@ -184,7 +184,7 @@ client = self.host.getClient(profile) if not client: error(_("Can't access profile's data")) - return + return try: song = OggVorbis(song_path) except OggVorbisHeaderError: @@ -213,7 +213,7 @@ self.host.profiles[profile].xmlstream.send(mess) radio_data = self.radios[jid.JID(referee).userhost()] #FIXME: referee comes from Libervia's client side, it's unsecure - radio_data['to_delete'][filename] = song_path #FIXME: works only because of the same host trick, see the note under the docstring + radio_data['to_delete'][filename] = song_path #FIXME: works only because of the same host trick, see the note under the docstring def playNext(self, room_jid, profile): """"Play next sont in queue if exists, and put a timer @@ -248,22 +248,22 @@ except KeyError: error(_("INTERNAL ERROR: can't find full path of the song to delete")) return - - #we wait more than the song length to delete the file, to manage poorly reactive networks/clients + + #we wait more than the song length to delete the file, to manage poorly reactive networks/clients reactor.callLater(length + 90, unlink, file_to_delete) #FIXME: same host trick (see above) def radiocol_game_cmd(self, mess_elt, profile): #FIXME: we should check sender (is it referee ?) here before accepting commands - from_jid = jid.JID(mess_elt['from']) + from_jid = jid.JID(mess_elt['from']) room_jid = jid.JID(from_jid.userhost()) radio_elt = mess_elt.firstChildElement() radio_data = self.radios[room_jid.userhost()] occupants_data = radio_data['occupants_data'] queue = radio_data['queue'] - + for elt in radio_elt.elements(): - + if elt.name == 'started': #new game created self.host.bridge.radiocolStarted(room_jid.userhost(), from_jid.full(), profile) elif elt.name == 'preload': #a song is in queue and must be preloaded @@ -279,7 +279,7 @@ elif elt.name == 'song_added': #a song has been added #FIXME: we are KISS for the proof of concept: every song is added, to a limit of 3 in queue. # Need to manage some sort of rules to allow peoples to send songs - + if len(queue) >= QUEUE_LIMIT: #there are already too many songs in queue, we reject this one mess = self.createRadiocolElt(room_jid) @@ -289,7 +289,7 @@ #FIXME: add an error code self.host.profiles[profile].xmlstream.send(mess) return - + #The song is accepted and added in queue queue.append((elt['filename'], float(elt['length']))) @@ -317,13 +317,13 @@ self.playNext(room_jid, profile) else: error (_('Unmanaged game element: %s') % elt.name) - + def getHandler(self, profile): return RadiocolHandler(self) class RadiocolHandler (XMPPHandler): implements(iwokkel.IDisco) - + def __init__(self, plugin_parent): self.plugin_parent = plugin_parent self.host = plugin_parent.host