Package elisa :: Package plugins :: Package bad :: Package coherence_plugin :: Module coherence_service
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.coherence_plugin.coherence_service

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17  """ 
18  UPnP MediaRenderer 
19  """ 
20   
21  __maintainer__ = "Philippe Normand <philippe@fluendo.com>" 
22   
23  from elisa.base_components import service_provider 
24  from elisa.core import common, component 
25  from coherence.base import Coherence 
26  from elisa.core.bus.bus_message import CoherencePlugin, CoherenceDevice 
27  import louie 
28   
29 -class CoherenceService(service_provider.ServiceProvider):
30 """ 31 32 """ 33 34 default_config = {'logmode':'warn', 35 'controlpoint': 'yes', 36 'plugins':{}} 37
38 - def initialize(self):
39 coherence_config = self.config 40 coherence_config['plugins'] = {} 41 try: 42 coherence_instance = Coherence(coherence_config) 43 except Exception, coherence_exception: 44 error = "Coherence failed to start. Error: %s" % coherence_exception 45 raise component.InitializeFailure(self.name, error) 46 self._coherence = coherence_instance 47 common.application.bus.register(self._got_message, CoherencePlugin, 48 CoherenceDevice)
49
50 - def _got_message(self, msg, sender):
51 if isinstance(msg, CoherencePlugin): 52 name = msg.name 53 args = msg.args 54 self.debug("Registering plugin %r", name) 55 self._coherence.add_plugin(name, **args) 56 else: 57 louie.connect(msg.callback, msg.name, msg.typ)
58
59 - def stop(self):
60 self._coherence.shutdown()
61