felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From furf...@apache.org
Subject svn commit: r400030 - in /incubator/felix/sandbox/furfari: ./ src/ src/it/ src/it/cnr/ src/it/cnr/isti/ src/it/cnr/isti/niche/ src/it/cnr/isti/niche/osgi/ src/it/cnr/isti/niche/osgi/upnp/ src/it/cnr/isti/niche/osgi/upnp/util/
Date Fri, 05 May 2006 09:43:14 GMT
Author: furfari
Date: Fri May  5 02:43:12 2006
New Revision: 400030

URL: http://svn.apache.org/viewcvs?rev=400030&view=rev
Log:
Utility code for developing UPnPDevice. Starting point if we want create helper classes that
manage the dispatching of UPnP Events to the EA Service (FELIX-68)

Added:
    incubator/felix/sandbox/furfari/felixwalk.gif   (with props)
    incubator/felix/sandbox/furfari/src/
    incubator/felix/sandbox/furfari/src/it/
    incubator/felix/sandbox/furfari/src/it/cnr/
    incubator/felix/sandbox/furfari/src/it/cnr/isti/
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/EventSource.java
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/Lookup.java
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPEventNotifier.java
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPStateVariableDescriptor.java
    incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPSubscriber.java

Added: incubator/felix/sandbox/furfari/felixwalk.gif
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/furfari/felixwalk.gif?rev=400030&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/felix/sandbox/furfari/felixwalk.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/EventSource.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/EventSource.java?rev=400030&view=auto
==============================================================================
--- incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/EventSource.java
(added)
+++ incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/EventSource.java
Fri May  5 02:43:12 2006
@@ -0,0 +1,36 @@
+/*
+DomoWare OSGi UPnP Sample TV Device is an implementation of UPnP Device service to be used
with OSGi Framework
+Copyright (C) 2004  Matteo Demuru, Francesco Furfari, Stefano "Kismet" Lenzi
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You can contact us at:
+	{matte-d, sygent, kismet-sl} [at] users.sourceforge.net
+*/
+package it.cnr.isti.niche.osgi.upnp.util;
+
+import java.beans.PropertyChangeListener;
+
+/**
+ * EventSource.java 8-feb-2005
+ * @author Francesco Furfari
+ */
+public interface EventSource {
+	void addPropertyChangeListener(PropertyChangeListener listener);
+	void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
+	void removePropertyChangeListener(PropertyChangeListener listener);
+	void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
+}
+

Added: incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/Lookup.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/Lookup.java?rev=400030&view=auto
==============================================================================
--- incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/Lookup.java (added)
+++ incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/Lookup.java Fri May
 5 02:43:12 2006
@@ -0,0 +1,94 @@
+/*
+DomoWare UPnP Base Driver is an implementation of the OSGi UnP Device Specifaction
+Copyright (C) 2005 Matteo Demuru, Francesco Furfari, Stefano "Kismet" Lenzi
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You can contact us at:
+	{matte-d, sygent, kismet-sl} [at] users.sourceforge.net
+*/
+
+package it.cnr.isti.niche.osgi.upnp.util;
+
+import java.util.MissingResourceException;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPService;
+
+/**
+ * Lookup.java 8-feb-2005
+ * @author Francesco Furfari
+ */
+public class Lookup {
+    
+    private final static String SERVICE_REFERENCE_MISSED = "Unable to locate the UPnPDevice
service reference";
+    private final static String SERVICE_MISSED = "Unable to locate the UPnPDevice service
";
+    private BundleContext context;
+    
+    public  Lookup(BundleContext context) {
+        this.context=context;
+    }
+
+    
+    public ServiceReference getDeviceReference(String deviceId){
+		try {
+		    String filter = "(" + UPnPDevice.ID + "="+ deviceId + ")";
+		    ServiceReference[] UPnPDevicesRef = context.getServiceReferences(UPnPDevice.class.getName(),filter);
+			if (UPnPDevicesRef != null)
+				for (int i = 0;i<UPnPDevicesRef.length;i++){
+				    return UPnPDevicesRef[i]; // the Device Id should be unique
+				}
+			return null;
+		} catch (Exception ex) {
+            ex.printStackTrace();
+			return null; 
+		}
+    }
+
+    public String getDeviceType(String deviceId){
+        ServiceReference sr = getDeviceReference(deviceId);
+        if (sr == null) throw new MissingResourceException(SERVICE_REFERENCE_MISSED,"ServiceReference",deviceId);
+        return (String) sr.getProperty(UPnPDevice.TYPE);
+    }
+
+    public Object getDeviceProperty(String deviceId,String key){
+        ServiceReference sr = getDeviceReference(deviceId);
+        if (sr == null) throw new MissingResourceException(SERVICE_REFERENCE_MISSED,"ServiceReference",deviceId);
+        return  sr.getProperty(key);
+    }
+
+    public String getServiceType(String deviceId, String serviceId){
+        ServiceReference sr = getDeviceReference(deviceId);
+        if (sr == null) throw new MissingResourceException(SERVICE_REFERENCE_MISSED,"ServiceReference",deviceId);
+		UPnPDevice device = (UPnPDevice) context.getService(sr);      
+        if (device == null) throw new MissingResourceException(SERVICE_MISSED,"UPnPDevice",deviceId);
+        String serviceType = null;
+		UPnPService service = device.getService(serviceId);
+        if (service != null) serviceType = service.getType();
+        context.ungetService(sr);
+        return serviceType;
+    }
+    
+    public boolean isRootDevice(String deviceId){
+        ServiceReference sr = getDeviceReference(deviceId);
+        if (sr == null) throw new MissingResourceException(SERVICE_REFERENCE_MISSED,"ServiceReference",deviceId);
+        String parent =  (String) sr.getProperty(UPnPDevice.PARENT_UDN);
+        if((parent == null)||parent.equals("")) return true;
+        return false;              
+    }
+    
+}

Added: incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPEventNotifier.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPEventNotifier.java?rev=400030&view=auto
==============================================================================
--- incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPEventNotifier.java
(added)
+++ incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPEventNotifier.java
Fri May  5 02:43:12 2006
@@ -0,0 +1,202 @@
+/*
+DomoWare OSGi UPnP Sample TV Device is an implementation of UPnP Device service to be used
with OSGi Framework
+Copyright (C) 2004  Matteo Demuru, Francesco Furfari, Stefano "Kismet" Lenzi
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You can contact us at:
+	{matte-d, sygent, kismet-sl} [at] users.sourceforge.net
+*/
+package it.cnr.isti.niche.osgi.upnp.util;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/**
+ * UPnPEventNotifier.java 8-feb-2005
+ * @author Francesco Furfari
+ */
+public class UPnPEventNotifier implements PropertyChangeListener,ServiceListener {
+	BundleContext context;
+	UPnPDevice device;
+	UPnPService service;
+	EventSource source;
+	
+	Properties UPnPTargetListener;
+	String deviceId;
+	String serviceId;
+	Vector upnpListeners = new Vector();
+	
+	public UPnPEventNotifier(BundleContext context,UPnPDevice device,UPnPService service,EventSource
source){
+	    if ((context == null) || (device == null) || (service == null))
+	        throw new IllegalArgumentException("Illegal arguments in UPnPEventNotifier constructor.");
+		this.context=context;
+		this.device=device;
+		this.service=service;
+		this.source=source;
+		this.serviceId=service.getId();
+		setupUPnPListenerHouseKeeping(device);
+	}
+	
+	/**
+	 * @param deviceId
+	 */
+	private void setupUPnPListenerHouseKeeping(UPnPDevice device) {
+		UPnPTargetListener = new Properties();
+		Dictionary dict = device.getDescriptions(null);
+		deviceId = (String) dict.get(UPnPDevice.ID);
+		UPnPTargetListener.put(UPnPDevice.ID,deviceId);
+		UPnPTargetListener.put(UPnPService.ID,serviceId);
+		UPnPTargetListener.put(UPnPDevice.TYPE,dict.get(UPnPDevice.TYPE));
+		UPnPTargetListener.put(UPnPService.TYPE,service.getType());
+		String ANY_UPnPEventListener = "("+Constants.OBJECTCLASS+"="+UPnPEventListener.class.getName()+")";
+		
+		ServiceReference[] listeners = null; 
+		try {
+			listeners = context.getServiceReferences(UPnPEventListener.class.getName(),null);
+			if (listeners != null){
+				for (int i = 0;i<listeners.length;i++){
+					ServiceReference sr = listeners[i];
+					Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
+					if (filter == null) addNewListener(sr);
+					else {				
+						if (filter.match(UPnPTargetListener))
+							addNewListener(sr);
+					}
+				}
+			}
+		} catch (Exception ex) {
+			System.out.println(ex);
+		}
+		
+	    try {
+	    	String filter = ANY_UPnPEventListener;
+			context.addServiceListener(this,filter);
+		} catch (Exception ex) {
+			System.out.println(ex);
+		}
+		
+		if (source!=null){
+			UPnPStateVariable[] vars = service.getStateVariables();
+			if (vars != null){
+				for (int i=0;i<vars.length;i++)
+					if(vars[i].sendsEvents())
+						source.addPropertyChangeListener(vars[i].getName(),this);
+			}
+		}
+		
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+	 */
+	public void propertyChange(PropertyChangeEvent evt) {
+		Iterator list = upnpListeners.iterator();
+		String property = evt.getPropertyName();
+		Object value = evt.getNewValue();
+		final Properties events = new Properties();
+		events.put(property,value);
+		while (list.hasNext()){
+			final ServiceReference sr = (ServiceReference)list.next();
+			new Thread(null,null,"UPnPEventNotifier"){
+				public void run(){
+					try {
+					    UPnPEventListener listener = (UPnPEventListener) context.getService(sr);
+						listener.notifyUPnPEvent(deviceId,serviceId,events);
+						context.ungetService(sr);
+					} catch (Exception ex){
+						System.out.println("UPnPEventNotifier Err: " + ex);
+						System.out.println("UPnPEventNotifier context: " + context);
+						System.out.println("UPnPEventNotifier listener: " + context.getService(sr));
+						System.out.println("UPnPEventNotifier sr: " +sr);
+					}
+				}
+			}.start();						
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+	 */
+	public void serviceChanged(ServiceEvent e) {
+		switch(e.getType()){
+			case ServiceEvent.REGISTERED:{
+				ServiceReference sr = e.getServiceReference();
+				Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
+				if (filter == null) addNewListener(sr);
+				else {				
+					if (filter.match(UPnPTargetListener))
+						addNewListener(sr);
+				}
+			};break;
+			
+            // thanks to Didier Donsez
+			case ServiceEvent.MODIFIED:{
+	               ServiceReference sr = e.getServiceReference();
+	               Filter filter = (Filter)	sr.getProperty(UPnPEventListener.UPNP_FILTER);
+	               removeListener(sr);
+	               if (filter == null)
+	                   addNewListener(sr);
+	               else {
+	                   if (filter.match(UPnPTargetListener))
+	                       addNewListener(sr);
+	               }
+	           };break; 
+			
+			case ServiceEvent.UNREGISTERING:{	
+				removeListener(e.getServiceReference());
+			};break;
+				
+		}
+		
+	}
+
+	private void removeListener(ServiceReference reference) {
+		upnpListeners.remove(reference);		
+	}
+
+	private void addNewListener(ServiceReference reference) {
+		upnpListeners.add(reference);	
+		UPnPStateVariable[] vars = service.getStateVariables();
+		if (vars != null){
+			for (int i=0;i<vars.length;i++)
+				if(vars[i].sendsEvents()){
+				    Object value = ((UPnPStateVariableDescriptor) vars[i]).getValue();
+				    propertyChange(new PropertyChangeEvent(this,vars[i].getName(),value,value));
+				}
+		}
+	}
+	
+	public void destroy(){
+		context.removeServiceListener(this);
+		upnpListeners.removeAllElements();
+	}
+}

Added: incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPStateVariableDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPStateVariableDescriptor.java?rev=400030&view=auto
==============================================================================
--- incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPStateVariableDescriptor.java
(added)
+++ incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPStateVariableDescriptor.java
Fri May  5 02:43:12 2006
@@ -0,0 +1,33 @@
+/*
+DomoWare UPnP Base Driver is an implementation of the OSGi UnP Device Specifaction
+Copyright (C) 2005 Matteo Demuru, Francesco Furfari, Stefano "Kismet" Lenzi
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You can contact us at:
+	{matte-d, sygent, kismet-sl} [at] users.sourceforge.net
+*/
+
+package it.cnr.isti.niche.osgi.upnp.util;
+
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/**
+ * UPnPStateVariableDescriptor.java 22-gen-2005
+ * @author Francesco Furfari
+ */
+public interface UPnPStateVariableDescriptor extends UPnPStateVariable {
+    Object getValue();
+}

Added: incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPSubscriber.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPSubscriber.java?rev=400030&view=auto
==============================================================================
--- incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPSubscriber.java
(added)
+++ incubator/felix/sandbox/furfari/src/it/cnr/isti/niche/osgi/upnp/util/UPnPSubscriber.java
Fri May  5 02:43:12 2006
@@ -0,0 +1,142 @@
+/*
+DomoWare OSGi UPnP Sample TV Device is an implementation of UPnP Device service to be used
with OSGi Framework
+Copyright (C) 2004  Matteo Demuru, Francesco Furfari, Stefano "Kismet" Lenzi
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You can contact us at:
+	{matte-d, sygent, kismet-sl} [at] users.sourceforge.net
+*/
+package it.cnr.isti.niche.osgi.upnp.util;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPService;
+
+/**
+ * UPnPSubscriber.java 8-feb-2005
+ * @author Francesco Furfari
+ */
+public class UPnPSubscriber {
+	private BundleContext context;
+	private UPnPEventListener listener;
+	private HashMap hash;
+	
+	private class Subscription implements UPnPEventListener{
+	    ServiceRegistration registration;
+	    
+	    Subscription(String keys){
+	 		try {
+				Filter filter = context.createFilter(keys);
+				Properties props = new Properties();
+				props.put(UPnPEventListener.UPNP_FILTER, filter);
+				registration = context.registerService(UPnPEventListener.class.getName(), this, props);
+			}catch (Exception ex){
+				System.out.println(ex);
+			}
+	    }
+	    
+	    public void unsubscribe(){
+			registration.unregister();
+	    }
+	    
+        public void notifyUPnPEvent(String arg0, String arg1, Dictionary arg2) {
+            listener.notifyUPnPEvent( arg0,  arg1,  arg2);
+        }
+	}
+	
+	
+	public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
+	    if ((context == null)|| (listener == null))
+	        throw new IllegalArgumentException("Illegal arguments in UPnPSubscriber constructor.");
+		this.context = context;
+		this.listener = listener;
+		hash = new HashMap();
+	}
+
+	public void subscribe(String filter){
+		if (hash.get(filter) == null){
+		    hash.put(filter, new Subscription(filter));
+		}	
+	}
+	
+	public void unsubscribe(String filter){
+		if (hash.containsKey(filter)) {
+		    Subscription subscription = (Subscription) hash.get(filter);
+		    subscription.unsubscribe();
+			hash.remove(filter);
+		}
+	}
+	
+	public void unsubscribeAll(){
+	    Iterator list = hash.entrySet().iterator();
+	    while (list.hasNext()){		        
+	        Map.Entry entry = (Map.Entry) list.next();
+	        Subscription subcription = (Subscription) entry.getValue();
+	        subcription.unsubscribe();
+		    list.remove();
+	    }
+	}
+
+	public String subscribeServiceIdOf(String deviceId, String serviceId){
+		String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" +
serviceId + "))";
+		subscribe(keys);
+		return keys;
+	}
+	
+	public String subscribeServiceTypeOf(String deviceId, String serviceType){
+		String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.TYPE + "="
+ serviceType + "))";
+		subscribe(keys);
+		return keys;
+	}
+	
+	public String subscribeEveryServiceType(String deviceType, String serviceType){
+		String keys = "(&(" + UPnPDevice.TYPE + "="+ deviceType + ")(" + UPnPService.TYPE +
"=" + serviceType + "))";
+		subscribe(keys);
+		return keys;
+	}
+	
+	public String subscribeAllServicesOf(String deviceId){
+		String keys = "(" + UPnPDevice.ID + "="+ deviceId + ")";
+		subscribe(keys);
+		return keys;
+	}
+	
+	public String subscribeEveryDeviceTypeServices(String deviceType){
+		String keys = "(" + UPnPDevice.TYPE + "="+ deviceType + ")";
+		subscribe(keys);
+		return keys;
+	}
+	
+	
+	public void unsubscribeServiceIdOf(String deviceId, String serviceId){
+		String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" +
serviceId + "))";
+		unsubscribe(keys);
+	}
+	
+	public void unsubscribeAllServicesOf(String deviceId){
+		String keys = "(" + UPnPDevice.ID + "="+ deviceId + ")";
+		unsubscribe(keys);
+	}
+}
\ No newline at end of file



Mime
View raw message