instrumentation: add next-share/
[cs-p2p-next.git] / instrumentation / next-share / BaseLib / UPnP / services / urlservice.py
1 # Written by Ingar Arntzen, Norut
2 # see LICENSE.txt for license information
3
4 """This module implements a URL UPnP Service."""
5
6 import types
7 from BaseLib.UPnP.upnpserver import UPnPService
8
9 DEFAULT_URL = "http://vg.no"
10
11
12 ##############################################
13 # URL SERVICE
14 ##############################################
15
16 class URLService(UPnPService):
17
18     """This class implements a simple URL service."""
19
20     def __init__(self, service_id):
21         UPnPService.__init__(self, service_id, 'URLService', 
22                              service_version=1)
23
24         # Define Evented Variable
25         self._url = self.define_evented_variable("URL", types.StringType, 
26                                                  DEFAULT_URL)
27
28         # Define Actions
29         self.define_action(self.get_url,
30                            out_args=[("URL", types.StringType)],
31                            name="GetURL")
32         self.define_action(self.set_url,
33                            in_args=[("URL", types.StringType)],
34                            name="SetURL")        
35
36     def get_url(self):
37         """Get the URL."""
38         return self._url.get()
39
40     def set_url(self, new_url):
41         """Set the URL."""
42         self._url.set(new_url)